我有一个表单,post="ModelSelector",当提交时,我们会遍历这些代码。我面临的问题是,我想检查$_POST的值,我知道它是通过调用"isset()"来设置的。
我只想打印/提醒/推出变量$productselection
function selectProduct() {
// save the post in a variable
$ProductSelections = $_POST['ModelSelector'];
// I want to print $ProductSelection to check its value
$frmVars['ProductSelections'] = $ProductSelections;
$frmVars['WindowSize'] = $WindowSize;
$frmVars['PageNum'] = 1;
saveFormValues(0,'RunDefMgr', $frmVars);
// Clear the checkboxes
$sel = array();
deleteRunDef(0,"*","RUN_DEF_EDIT","*");
}
if(isset($_POST['ModelSelector'])) {
selectProduct();
}
我尝试过ECHO,由于某种原因,它没有以HTML格式打印值。提前谢谢。
我想检查$_POST 的值
$_POST
将是一个数组。
使用print_r($_POST)
或var_dump($_POST)
查看其内容。
您的表单方法应该是method="POST"
,您可以使用以下编辑来查看它是否有效,因为您必须将$_POST (array)
传递给函数才能在函数内部使用它。函数需要一个参数,否则$_POST
不存在。
还可以启用文件中的错误来检查您使用ini_set('display_errors',1);
或error_reporting(E_ALL);
得到的错误类型
function selectProduct($_POST) { // create parameter $_POST which we get from isset condition.
// save the post in a variable
$ProductSelections = $_POST['ModelSelector'];
print_r($ProductSelections); // print the value.
// I want to print $ProductSelection to check its value
$frmVars['ProductSelections'] = $ProductSelections;
$frmVars['WindowSize'] = $WindowSize;
$frmVars['PageNum'] = 1;
saveFormValues(0,'RunDefMgr', $frmVars);
// Clear the checkboxes
$sel = array();
deleteRunDef(0,"*","RUN_DEF_EDIT","*");
}
if(isset($_POST['ModelSelector'])) {
selectProduct($_POST); // pass the $_POST array to the selectProduct function.
}