[英]How can I detect the name of my current URL if I include my php script on another page?
This is my home.php
: 这是我的home.php
:
require('header.php');
This is my header.php
这是我的header.php
if (basename(__FILE__) == "home.php"){
echo "you are on home.php";
} else {
echo "you are not on home.php";
}
When I now open the URL www.mypage.com/home.php
I see the text you are not on home.php
当我现在打开URL www.mypage.com/home.php
我看到you are not on home.php
Try something like this 试试这个
<?php
$explode = explode("/", $_SERVER['REQUEST_URI']);
$explode = explode("?", $explode[count($explode)-1]);
echo $explode[0];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.