从PHP手册中:
('。=')是串联分配运算符,它在左侧的参数上附加了参数。
在您的脚本中,左侧的参数为空,它将生成一个e_notice,说换句话说,变量不确定。
$message
$message
变量在循环之外不存在,因此您将附加到不存在的变量附加。 this应该修复它:
$message = ""; //initialize it
foreach($_POST['form_data'] as $item)
{
//Asigning the message fields to $message variable.
$message .= $item;
...
}
给出的代码正常工作,所有值都在$ _ post中填充。 检查一下,让我们知道结果
array(3) { ["email_address"]=> string(22) "[email protected]" ["email_subject"]=> string(11) "Hello World" ["form_data"]=> array(3) { [0]=> string(5) "dwdcw" [1]=> string(2) "fw" [2]=> string(3) "dfw" } }