如题所述
pathinfo
[php] view plaincopy
<?php
$test = pathinfo("http://localhost/index.php");
print_r($test);
?>
ç»æå¦ä¸
Array
(
[dirname] => http://localhost //urlçè·¯å¾
[basename] => index.php //å®æ´æ件å
[extension] => php //æ件ååç¼
[filename] => index //æ件å
)
parse_url
[php] view plaincopy
<?php
$test = parse_url("http://localhost/index.php?name=tank&sex=1#top");
print_r($test);
?>
ç»æå¦ä¸
Array
(
[scheme] => http //使ç¨ä»ä¹åè®®
[host] => localhost //主æºå
[path] => /index.php //è·¯å¾
[query] => name=tank&sex=1 // æä¼ çåæ°
[fragment] => top //åé¢æ ¹çéç¹
)
basename
[php] view plaincopy
<?php
$test = basename("http://localhost/index.php?name=tank&sex=1#top");
echo $test;
?>
ç»æå¦ä¸
index.php?name=tank&sex=1#top
[php] view plaincopy
<?php
$test = pathinfo("http://localhost/index.php");
print_r($test);
?>
ç»æå¦ä¸
Array
(
[dirname] => http://localhost //urlçè·¯å¾
[basename] => index.php //å®æ´æ件å
[extension] => php //æ件ååç¼
[filename] => index //æ件å
)
parse_url
[php] view plaincopy
<?php
$test = parse_url("http://localhost/index.php?name=tank&sex=1#top");
print_r($test);
?>
ç»æå¦ä¸
Array
(
[scheme] => http //使ç¨ä»ä¹åè®®
[host] => localhost //主æºå
[path] => /index.php //è·¯å¾
[query] => name=tank&sex=1 // æä¼ çåæ°
[fragment] => top //åé¢æ ¹çéç¹
)
basename
[php] view plaincopy
<?php
$test = basename("http://localhost/index.php?name=tank&sex=1#top");
echo $test;
?>
ç»æå¦ä¸
index.php?name=tank&sex=1#top
温馨提示:答案为网友推荐,仅供参考