我有两个PHP脚本。一个发布消息“Hello”,而另一个接收消息。目前,第二个PHP脚本收到_POST ['message'],但该消息的内容为空!
脚本一:
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_POSTFIELDS, array(
'message' => 'Hello'
));
$result = curl_exec($ch);
if($result) {
echo("Successful post");
}
curl_close($ch);
脚本二:
if($_POST['message']) {
echo("received post message");
echo ("message:" . $POST['message']);
目前脚本2打印“收到邮件消息后:”
我完全陷入困境 - 从this post开始,看来我的语法是正确的......
答案 0 :(得分:1)
脚本2的语法错误,必须是$_POST
。
if($_POST['message']) {
echo("received post message");
echo ("message:" . $_POST['message']);