如果可以存储来自 Curl 脚本的回显结果,是否有人不。
脚本示例已提交至:
\\some code to generate images using imagick and the post variables
$array = array(1,2,3,4,5,6,7,8,9);
$result = json_encode($array);
echo $result;
卷曲示例:
$id = 1;
$champ = array("product" => "1","id"=> $id,"occasion"=> $o,"field1" => "1991","field2" => "test","field3" =>"test1","field4" => "test2","field5" =>"test3","field6" =>"test4","field7" =>"test5","field8" =>"test6","test7");
foreach($champ as $key => $data){
$field_string .= $key."=".$data."&";
}
rtrim($field_string, "&");
$url = "http://www.test.com/website/script.php";
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_POST, count($champ));
curl_setopt($ch,CURLOPT_POSTFIELDS, $field_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, FALSE);
$result = curl_exec($ch);
$array = json_decode($result);
curl_close($ch);
var_dump($array);
如果我 var_dump($result) 我得到一个 bool(true) 所以我知道脚本已正确执行并且输出显示在屏幕上但是我似乎无法将信息存储到要处理的变量中。
先感谢您