<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://localhost/myphp/dump.php" );
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt($ch, CURLOPT_POST, 1 );
curl_setopt($ch, CURLOPT_POSTFIELDS, "success" );
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: text/plain'));
$return = curl_exec($ch);
if($return === false)
{
echo 'Curl error: ' . curl_error($ch);
}
else
{
echo $return.' Operation completed without any errors';
}
?>
dump.php
<?php
$str = print_r(file_get_contents('php://input'),true);
file_put_contents('a.txt',$str,FILE_APPEND);
echo file_get_contents('php://input');
?>