Home >Backend Development >PHP Tutorial >Example of php curl simulating post request_PHP tutorial

Example of php curl simulating post request_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 10:41:29771browse

1, local machine:
// '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);

2, remote server:

if(isset($_POST['name'])){
if(!empty($_POST['name'])){
echo 'Hello,',$_POST['name '].'! ';
}
}

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/687414.htmlTechArticle1, local machine: $uri = "http://www.jbxue.com/test.php"; //Replace here with the address of your own server // Parameter array $data = array ( 'name' = 'tanteng' // 'password' = 'password' )...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn