开发者

Extract URL in PHP

开发者 https://www.devze.com 2023-02-08 17:49 出处:网络
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

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

精彩评论

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