本文介绍了如果url变量为空,则重定向到主页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我无法使它正常工作!
我有一个view.php页面,该页面使用'ID'变量来检索数据库信息.
所以我的网址是这样的:
/view.php?id=23如果他们删除了网址的"23"部分,我试图让它将"用户重定向"到主页.
所以当您访问
/view.php?id=应该:
if(isset($_GET['id']) == "") { header('Location: /'); exit; }如果我访问的话就可以
/view.php解决方案
尝试使用 empty() :
if(empty($_GET['id'])) { header('Location: /'); exit; }I am not able to get this to work correctly!!
I have a view.php page that uses a variable of 'ID' to retrieve db info.
So my url is like this:
/view.php?id=23I am trying to get it to "redirect" the user to the home page if they erase the "23" part of the url.. ?
so when you visit
/view.php?id=It should :
if(isset($_GET['id']) == "") { header('Location: /'); exit; }Works if I visit
/view.php解决方案
Try using empty():
if(empty($_GET['id'])) { header('Location: /'); exit; }
更多推荐
如果url变量为空,则重定向到主页
发布评论