当前位置: 首页 > 工具软件 > PHP Web Stat > 使用案例 >

CURL PHP POST raw data

干子瑜
2023-12-01
<?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');

?>


 类似资料:

相关阅读

相关文章

相关问答