21,886
社区成员
发帖
与我相关
我的任务
分享
<?php
$uri = "http://localhost/handle.php";
// 参数数组
$data = array (
'name' => 'tanteng'
// 'password' => 'password'
);
$ch = curl_init ();
// print_r($ch);
curl_setopt ( $ch, CURLOPT_URL, $uri );
curl_setopt ( $ch, CURLOPT_POST, 1 );
curl_setopt ( $ch, CURLOPT_HEADER, 0 );
curl_setopt ( $ch, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt ( $ch, CURLOPT_POSTFIELDS, $data );
$return = curl_exec ( $ch );
curl_close ( $ch );
print_r($return);
?>
handle.php
<?php
$name = isset($_POST['name'])? $_POST['name'] : '';
file_put_contents('tt.txt', $name, true);
echo 'success';
?>
b.php
<?php
echo 'this is the posted data';
if(file_exists('tt.txt')){
$name = file_get_contents('tt.txt');
if(!empty($name)){
echo '您好,',$name.'!';
}
}
?>