[英]In php how to hide contents of a page if url not matched
I have a page demo.php. 我有一个页面demo.php。 In this page I have some contents. 在此页面中,我有一些内容。 Also I am passing values to the URL demo.php?id=1. 另外,我将值传递给URL demo.php?id = 1。 This url generates dynamically. 该网址是动态生成的。 This url has some contents. 这个网址有一些内容。
I want to hide the contents of demo.php in demo.php?id=1. 我想将demo.php的内容隐藏在demo.php?id = 1中。
My Logic 我的逻辑
if(basename(__FILE__, '.php')=='demo'){
//Show demo.php contents
}
else{
$id=$_GET['id'];
}
This is not working. 这是行不通的。 This only hides the content of demo.php?id=1 in demo.php Not hiding the content of demo.php in demo.php?id=1 这只会在demo.php中隐藏demo.php?id = 1的内容,不会在demo.php?id = 1中隐藏demo.php的内容
Please help me to solve to hide the content of demo.php in demo.php?id=1. 请帮助我解决将demo.php的内容隐藏在demo.php?id = 1中。
Test for ?id= instead of the file name 测试?id =而不是文件名
if(!isset($_GET['id'])){
//Show demo.php contents
}
else{
$id=$_GET['id'];
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.