php当前url完整
A. 请问下 php 怎么获取 ajax 请求 来源页面的 完整 url 地址啊
$_SERVER['HTTP_REFERER'] //这个参数可以完全获取,页面来源
不过,需要注意,锚链接是不能获取的,
比如:xx.php?name=123#1234
获取的地址是 xx.php?name=123
因为锚链接是前台的东西,是不会发送到后台去的
B. thinkphp 怎么获取当前的url完整
<?php
echo$_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
若需要显示协议
<?php
echo$_SERVER["REQUEST_SCHEME"].'://'.$_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
C. php如何获取当前的url
<?php
$url=($_SERVER['HTTP_HTTPS']?'https':'http').'://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
echo$url;
?>
D. PHP $_GET['url'];怎么传入完整的url
#后面的内容PHP无法获取,只有js可以获取,JS代码示例:
<script type="text/javascript">
document.write(location.href);
</script>
E. php或者js如何取得完整url包括url中含有#的部分,比如:index.php#ac=5
用js的window.location.href,下面是代码:
function test() {
alert(window.location.href);
}
<a href="#" onclick="test()">test</a>
F. thinkphp 怎么获取当前的url完整
<?php
/**
*获取当前页面完整URL地址
*/
functionget_url(){
$sys_protocal=isset($_SERVER['SERVER_PORT'])&&$_SERVER['SERVER_PORT']=='443'?'https://':'http://';
$php_self=$_SERVER['PHP_SELF']?$_SERVER['PHP_SELF']:$_SERVER['SCRIPT_NAME'];
$path_info=isset($_SERVER['PATH_INFO'])?$_SERVER['PATH_INFO']:'';
$relate_url=isset($_SERVER['REQUEST_URI'])?$_SERVER['REQUEST_URI']:$php_self.(isset($_SERVER['QUERY_STRING'])?'?'.$_SERVER['QUERY_STRING']:$path_info);
return$sys_protocal.(isset($_SERVER['HTTP_HOST'])?$_SERVER['HTTP_HOST']:'').$relate_url;
}
echoget_url();
?>
G. php获取url参数
1、在当前网页echo出变量$_SERVER['HTTP_HOST']即可获取域名或主机地址。
H. 怎么通过PHP代码获取带#的完整的URL
使用正则表达式获取
匹配网址URL的正则表达式:^[a-zA-z]+://(\\w+(-\\w+)*)(\\.(\\w+(-\\w+)*))*(\\?\\S*)?$
I. php如何获取当前页面url路径
function curPageURL() {
$pageURL = 'http';
if ($_SERVER["HTTPS"] == "on")
{
$pageURL .= "s";
}
$pageURL .= "://";
if ($_SERVER["SERVER_PORT"] != "80")
{
$pageURL .= $_SERVER["SERVER_NAME"] . ":" . $_SERVER["SERVER_PORT"] .
$_SERVER["REQUEST_URI"];
}
else
{
$pageURL .= $_SERVER["SERVER_NAME"] .
$_SERVER["REQUEST_URI"];
}
return $pageURL;}?>
(9)php当前url完整扩展阅读:
获取域名或主机地址 :echo $_SERVER['HTTP_HOST'].""; #localhost
获取网页地址:echo $_SERVER['PHP_SELF'].""; #/blog/testurl.php
3.获取网址参数:echo $_SERVER["QUERY_STRING"].""; #id=5
4.获取用户代理:echo $_SERVER['HTTP_REFERER']."";
J. 怎么用php获取当前url 然后存入文档
//获取域名或主机地址
echo $_SERVER['HTTP_HOST']."<br>"; #localhost
//获取网页地址
echo $_SERVER['PHP_SELF']."<br>"; #/blog/testurl.php
//获取网址参数
echo $_SERVER["QUERY_STRING"]."<br>"; #id=5
//获取用户代理
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://localhost/blog/testurl.php?id=5
//包含端口号的完整url
echo 'http://'.$_SERVER['SERVER_NAME'].':'.$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
#http://localhost:80/blog/testurl.php?id=5
//只取路径
$url='http://'.$_SERVER['SERVER_NAME'].$_SERVER["REQUEST_URI"];
echo dirname($url);
写入文件
$file = "paypal_back.log";
file_put_contents($file, $url, FILE_APPEND);