I have a php script by the following address C:\Denwer\home\localhost\www\upload_record_test.php
.
This script shows some text. But if I try to execute this script from the commmand line by command php C:\Denwer\home\localhost\www\upload_record_test
, I get the html response with many errors and the message Call to undefined function curl_init()
. The code:
<?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);
}
?>
Please, tell me, how can I execute this script from the command line and get only resulted text? Thanks in advance.