【发布时间】:2013-10-01 21:19:13
【问题描述】:
我正在为 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];
但不返回任何值...
【问题讨论】:
-
$_GET['$url_before'] != $_GET[$url_before],去掉引号。 -
除了引号的事情,他确实说未引用的版本仍然没有返回任何内容
-
您可能需要检查整个
$_GET数组中的内容,以防$url_before设置不正确..
标签: php wordpress variables parameters get