php获取帝国CMS各种路径的几种方法
2020-05-29 站长 站长日志
获取帝国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实现获取当前页面的完整地址
测试网址: http://www.11px.cn/showinfo-34-4035-0.html <? //获取域名或主机地址 echo $_SERVER ['HTTP_HOST']."<br>"; # www.11px.cn //获取网页地址 echo $_SERVER ['PHP_SELF']."<br>"; # /e/action/ShowInfo.php //获取网址参数 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 ?>
上一篇:帝国常用的PHP判断语法集合
下一篇:帝国CMS专题如何调用自定义字段