获取帝国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.78moban.cn/showinfo-34-4035-0.html
<?
//获取域名或主机地址
echo $_SERVER ['HTTP_HOST'].<br>; # www.78moban.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.78moban.cn/showinfo-34-4035-0.html
# http://www.78moban.cn/e/action/ShowInfo.php?classid=34&id=4035&page=0
//包含端口号的完整url
echo 'http://'. $_SERVER ['SERVER_NAME'].':'. $_SERVER [SERVER_PORT]. $_SERVER [REQUEST_URI];
# http://78moban.cn:80/showinfo-34-4035-0.html
//只取路径
$url ='http://'. $_SERVER ['SERVER_NAME']. $_SERVER [REQUEST_URI];
echo dirname ( $url );
# http://78moban.cn
?>
本文链接:http://78moban.cn/post/16482.html
版权声明:站内所有文章皆来自网络转载,只供模板演示使用,并无任何其它意义!