如何在参数$ _GET中使用变量?例如:($ _GET [$ my_var]) [英] How to use variable inside parameter $_GET? example: ($_GET[$my_var])
问题描述
我正在为wordpress开发一个插件,根据用户通过Wordpress管理面板的偏好将$ _GET的参数记录在数据库中。下面的验证必须通过$ _GET,这是一个函数:
$ db_url = get_option('my_get_url');
//返回用户输入的数据库的值
//在这种情况下return - > page = nosupport
$ url_explode = explode(=,$ db_url);
$ url_before = $ url_explode [0]; // - >页面
$ url_after = $ url_explode [1]; // - > nosupport
echoBefore:。$ url_before; //这里没关系,返回 - >页面
echoAfter:。$ url_after; //这里没关系,返回 - >没有支持
我的问题在这里:
<$ p $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $' $ _GET ['$ url_before'] ==nosupport){
// my function goes here ...
}
}
我使用测试参数:
echo $ _GET [$ url_before];
但是不要返回任何值...
$ _ GET [$ url_before]
$ _GET [$ url_before]
问题已解决,感谢您的帮助。
I'm developing a plugin for wordpress, the parameter of the $ _GET is recorded in the database according to the preference of the User via the Wordpress Admin Panel. The following validation has to be via the $ _GET, this is the function:
$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
My problem is here:
// here $_GET no have any value, dont work on validate...
if($_GET[$url_before] != ""){
if($_GET['$url_before']=="nosupport"){
// my function goes here...
}
}
I using for test the parameter:
echo $_GET[$url_before];
But dont return any value...
I found the problem, i had already tested all of these options, but ever dont working, the problem was that I was testing the function inside the main page of my site, and on the main page (mysite.com) does not get the parameter (?page=nossuport), so always returning null values, when I used the variable in the GET or used the echo $GET[$my_var] to test.. It was a great carelessness of mine, would never work...
by the way, the two parameters works correctly:
$_GET[$url_before]
$_GET["$url_before"]
The Problem are solved, Thanks for help.
这篇关于如何在参数$ _GET中使用变量?例如:($ _GET [$ my_var])的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!