如何从卷曲得到变量值
问题描述:
<?php
$message=$_POST["msg"];
echo $message;
// create a new cURL resource
$ch = curl_init();
// set URL and other appropriate options
curl_setopt($ch, CURLOPT_URL, "http://.../pl1.php?
m=$message");
curl_setopt($ch, CURLOPT_HEADER, 0);
// grab URL and pass it to the browser
curl_exec($ch);
// close cURL resource, and free up system resources
curl_close($ch);
?>
上面的代码是IAM using.anyone建议我我如何得到m的值pl1.php如何从卷曲得到变量值
我收到以下错误: 您的浏览器发送的请求该服务器无法理解。
答
试试这个代码:
<?php
$message=$_POST["msg"];
echo $message;
// curl initialize
$ch = curl_init();
// set curl options
curl_setopt($ch, CURLOPT_URL, "http://.../pl1.php?
m=$message");
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
// execute request and return response
$output = curl_exec($ch);
echo $output;
// close cURL request
curl_close($ch);
?>
并得到网页上的数据pl1.php使用$ _GET [ 'M'];
但是,我相信用post方法使用curl发送数据比get方法好。
谢谢
'$ _GET ['m']''如何?这是PHP 101.在将其添加到URL之前,您还应该[urlencode](http://php.net/manual/en/function.urlencode.php)该消息。 –
如果我们假设你的代码没有任何错误,并且它发送的请求正确,这应该在'pl1.php' - >'$ mMessage = $ _GET ['m'];''应该工作。 –
因此,有没有任何建议为你工作?有些反馈会很好。 –