parse_url类似于$_SERVER
它的用途是获取网址
相比而言,$_SRVER获取的网址的信息更多,更具体一些
下面说一下parse_url:
<?php
$Url='http://www.yidawang.net/index.html';
$tempu=parse_url($Url);
print_r($tempu);die;
打印的结果为:Array( [scheme] => http [host] => www.yidawang.net [path] => /index.html)
$message=$tempu['host'];
echo $message;
输出的结果为:www.yidawat_ng.net(域名)
?>
而$_SERVER
echo "<pre>";
print_r($_SERVER);
Array ( [PATH] => D:\phpStudy\php55n;C:\Users\59106\Desktop\node-v8.1.3-win-x64\node-v8.1.3-win-x64;E:\yu\vue\my-project;C:\Users\59106\AppData\Local\Microsoft\WindowsApps; [SYSTEMROOT] => C:\WINDOWS [COMSPEC] => C:\WINDOWS\system32\cmd.exe [PATHEXT] => .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC [WINDIR] => C:\WINDOWS [PHP_FCGI_MAX_REQUESTS] => 1000 [PHPRC] => D:/phpStudy/php55n [_FCGI_SHUTDOWN_EVENT_] => 2080 [SCRIPT_NAME] => /test10.php [REQUEST_URI] => /test10.php [QUERY_STRING] => [REQUEST_METHOD] => GET [SERVER_PROTOCOL] => HTTP/1.1 [GATEWAY_INTERFACE] => CGI/1.1 [REMOTE_PORT] => 54677 [SCRIPT_FILENAME] => E:/wamp/www/test10.php [SERVER_ADMIN] => www.goods.com [CONTEXT_DOCUMENT_ROOT] => E:/wamp/www [CONTEXT_PREFIX] => [REQUEST_SCHEME] => http [DOCUMENT_ROOT] => E:/wamp/www [REMOTE_ADDR] => 127.0.0.1 [SERVER_PORT] => 80 [SERVER_ADDR] => 127.0.0.1 [SERVER_NAME] => www.goods.com [SERVER_SOFTWARE] => Apache/2.4.18 (Win32) OpenSSL/1.0.2e mod_fcgid/2.3.9 [SERVER_SIGNATURE] => [SystemRoot] => C:\WINDOWS [HTTP_UPGRADE_INSECURE_REQUESTS] => 1 [HTTP_CONNECTION] => close [HTTP_DNT] => 1 [HTTP_ACCEPT_ENCODING] => gzip, deflate [HTTP_ACCEPT_LANGUAGE] => zh-CN,zh;q=0.8,en-US;q=0.5,en;q=0.3 [HTTP_ACCEPT] => text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 [HTTP_USER_AGENT] => Mozilla/5.0 (Windows NT 10.0; WOW64; rv:54.0) Gecko/20100101 Firefox/54.0 [HTTP_HOST] => www.goods.com [FCGI_ROLE] => RESPONDER [PHP_SELF] => /test10.php [REQUEST_TIME_FLOAT] => 1499823769.6059 [REQUEST_TIME] => 1499823769 )