wordpress/PHP-访问post和get变量

wordpress/PHP-访问post和get变量,php,wordpress,post,get,Php,Wordpress,Post,Get,谁能告诉我为什么我没有从wordpress模板中提交的表单中检索信息?正在传递变量,但它们没有值 请检查表单方法 <form name="frmlist" method="post"> 试试这个 print var_dump($_GET); print var_dump($_POST); 刚刚遇到相同/相似的问题;在Wordpress上使用get变量并不理想,因为URL是使用mod_rewrite构建的,并且有一些保留的查询参数。该列表提供了一个列表,但并不全面 总之,您使用的

谁能告诉我为什么我没有从wordpress模板中提交的表单中检索信息?正在传递变量,但它们没有值

请检查表单方法

<form name="frmlist" method="post">

试试这个

print var_dump($_GET);
print var_dump($_POST);

刚刚遇到相同/相似的问题;在Wordpress上使用get变量并不理想,因为URL是使用mod_rewrite构建的,并且有一些保留的查询参数。该列表提供了一个列表,但并不全面

总之,您使用的变量可能是Wordpress保留、修改或处理的变量之一


(我知道这是一个老问题,但它需要回答或澄清。)

一个老问题的新答案

我偶然发现了这篇没有帮助的帖子,并编写了我自己的实用程序(很高兴地与大家分享,并随时改进)


不幸的是。不是在wordpress中。
/* Get Parameters from $_POST and $_GET (WordPress)
    $param = string name of specific parameter requested (default to null, get all parameters
    $null_return = what you want returned if the parameter is not set (null, false, array() etc

    returns $params (string or array depending upon $param) of either parameter value or all parameters by key and value

    Note:   POST overrules GET (if both are set with a value and GET overrules POST if POST is not set or has a non-truthful value
            All parameters are trimmed and sql escaped
*/

function wordpress_get_params($param = null,$null_return = null){
    if ($param){
        $value = (!empty($_POST[$param]) ? trim(esc_sql($_POST[$param])) : (!empty($_GET[$param]) ? trim(esc_sql($_GET[$param])) : $null_return ));
        return $value;
    } else {
        $params = array();
        foreach ($_POST as $key => $param) {
            $params[trim(esc_sql($key))] = (!empty($_POST[$key]) ? trim(esc_sql($_POST[$key])) :  $null_return );
        }
        foreach ($_GET as $key => $param) {
            $key = trim(esc_sql($key));
            if (!isset($params[$key])) { // if there is no key or it's a null value
                $params[trim(esc_sql($key))] = (!empty($_GET[$key]) ? trim(esc_sql($_GET[$key])) : $null_return );
            }
        }
        return $params;
    }
}