我有一个通过以下地址的 php 脚本C:\Denwer\home\localhost\www\upload_record_test.php
。此脚本显示一些文本。但是,如果我尝试从命令行按命令执行此脚本php C:\Denwer\home\localhost\www\upload_record_test
,我会得到包含许多错误和消息的 html 响应Call to undefined function curl_init()
。编码:
<?php
$_POST_DATA=array();
$_POST_DATA['id']='AccountPagesView.a_book/45';
$_POST_DATA['old_value']='1';
$_POST_DATA['value']='2';
$ch=curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://localhost/index.php/welcome/update_record');
curl_setopt($ch, CURLOPT_POSTFIELDS, $_POST_DATA);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_VERBOSE, 1);
$real_result=curl_exec($ch);
$expected_result=array('result'=>'LOGIN', 'old_value'=>'1');
$real_result=json_decode($real_result, true);
if (count(array_intersect($real_result, $expected_result))==2)
{
echo "THE TEST HAS BEEN COMPLETED";
}
else
{
echo "THE TEST HASN'T BEEN COMPLETED<br/>";
echo "RESULT:";
print_r($real_result);
echo "<br/>EXPECTED RESULT:";
print_r($expected_result);
}
?>
请告诉我,如何从命令行执行此脚本并仅获取结果文本?提前致谢。