獲取帝國CMS路徑方法1
<?php $url_this = 'http://'.$_SERVER['SERVER_NAME'].$_SERVER["REQUEST_URI"]; //只取路徑 ?> <?=$url_this?>
獲取帝國CMS路徑方法2
<?php $url_this = "http://".$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'].'?'.$_SERVER['QUERY_STRING'];//獲取完整的url ?> <?=$url_this?>
PHP實(shí)現(xiàn)獲取當(dāng)前頁面的完整地址
測試網(wǎng)址: http://www.11px.cn/showinfo-34-4035-0.html <? //獲取域名或主機(jī)地址 echo $_SERVER ['HTTP_HOST']."<br>"; # www.11px.cn //獲取網(wǎng)頁地址 echo $_SERVER ['PHP_SELF']."<br>"; # /e/action/ShowInfo.php //獲取網(wǎng)址參數(shù) echo $_SERVER ["QUERY_STRING"]."<br>"; # classid=34&id=4035&page=0 //獲取用戶代理 echo $_SERVER ['HTTP_REFERER']."<br>"; // 獲取完整的url echo 'http://'. $_SERVER ['HTTP_HOST']. $_SERVER ['REQUEST_URI']; echo 'http://'. $_SERVER ['HTTP_HOST']. $_SERVER ['PHP_SELF'].'?'. $_SERVER ['QUERY_STRING']; #http://www.11px.cn/showinfo-34-4035-0.html # http://www.11px.cn/e/action/ShowInfo.php?classid=34&id=4035&page=0 //包含端口號的完整url echo 'http://'. $_SERVER ['SERVER_NAME'].':'. $_SERVER ["SERVER_PORT"]. $_SERVER ["REQUEST_URI"]; # http://11px.cn:80/showinfo-34-4035-0.html //只取路徑 $url ='http://'. $_SERVER ['SERVER_NAME']. $_SERVER ["REQUEST_URI"]; echo dirname ( $url ); # http://11px.cn ?>
版權(quán)聲明: 本站資源均來自互聯(lián)網(wǎng)或會員發(fā)布,如果侵犯了您的權(quán)益請與我們聯(lián)系,我們將在24小時內(nèi)刪除!謝謝!
轉(zhuǎn)載請注明: php獲取帝國CMS各種路徑的幾種方法