我正在开发一个WordPress插件,$_GET的参数根据用户的偏好通过Wordpress管理面板记录在数据库中。以下验证必须通过 $_GET 进行,这是函数:
$db_url = get_option('my_get_url');
// returns the value of the database entered by User
// on this case return --> page=nosupport
$url_explode = explode("=", $db_url);
$url_before = $url_explode[0]; // --> page
$url_after = $url_explode[1]; // --> nosupport
echo "Before: ".$url_before; // here are ok, return --> page
echo "After: ".$url_after; // here are ok, return --> nosupport
我的问题在这里:
// here $_GET no have any value, dont work on validate...
if($_GET[$url_before] != ""){
if($_GET['$url_before']=="nosupport"){
// my function goes here...
}
}
我用来测试参数:
echo $_GET[$url_before];
但不返回任何值...
我发现了问题,我已经测试了所有这些选项,但从来没有工作过,问题是我正在网站主页内测试该功能,并且在主页(mysite.com)上没有得到参数(?page=nossuport),所以总是返回空值,当我在GET中使用该变量或使用echo $GET[$my_var]进行测试时..这是我的一个很大的粗心,永远不会工作。 ..
顺便说一句,这两个参数工作正常:
$_GET[$url_before]
$_GET["$url_before"]
问题已解决,感谢帮助。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)