2017-07-02 17 views

回答

1

parse_url()功能。

parse_url('http://www.loadedcamp.net/music/63637-adele-hello', PHP_URL_PATH); 

輸出:/music/63637-adele-hello

2

您可以通過php parse_url()方法獲取url的完整信息。

$foo = "http://www.loadedcamp.net/music/63637-adele-hello"; 
$blah = parse_url($foo); 
print_r($blah); 
Array 
(
    [scheme] => http 
    [host] => www.loadedcamp.net 
    [path] => /music/63637-adele-hello 
    [query] => 
) 

print_r($blah['path']);//prints /music/63637-adele-hello 

你也可以在這裏使用這樣

evho parse_url('http://www.loadedcamp.net/music/63637-adele-hello', PHP_URL_PATH);//prints /music/63637-adele-hello