开发者

Extract URL in PHP

I want to create a command line tool for web. something similar to the website futz[dot]me.

I want users to enter in their addressbar : mydomain.com/anytext

& want to extract "anytext" in PHP. How can I do this??

I tried this using HTT开发者_Go百科P Referrer but getting 404 error.


From PHP documentation: parse_url()

<?php
$url = 'http://username:password@hostname/path?arg=value#anchor';

print_r(parse_url($url));

echo parse_url($url, PHP_URL_PATH);
?>

Output:

Array
(
    [scheme] => http
    [host] => hostname
    [user] => username
    [pass] => password
    [path] => /path
    [query] => arg=value
    [fragment] => anchor
)
/path


You could do this using mod_rewrite and it would essentially pass it off as a regular parameter

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜