我需要从当前请求的URL获取路径。 例如,如果当前的网址是:
"http://www.example.com/example/test/hi.php?randomvariable=1"
我想这样的:
"/example/test/hi.php?randomvariable=1"
我需要从当前请求的URL获取路径。 例如,如果当前的网址是:
"http://www.example.com/example/test/hi.php?randomvariable=1"
我想这样的:
"/example/test/hi.php?randomvariable=1"
你想$_SERVER['REQUEST_URI']
。 从该文档 :
'REQUEST_URI'
这是为了访问此页面所需的URI。 例如,
'/index.html'
它应该是 :
$_SERVER['REQUEST_URI'];
看一看: 获取PHP的完整URL
<?php
function current_url()
{
$url = "http://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
$validURL = str_replace("&", "&", $url);
return $validURL;
}
//echo "page URL is : ".current_url();
$offer_url = current_url();
?>
<?php
if ($offer_url == "checking url name") {
?> <p> hi this is manip5595 </p>
<?php
}
?>