从PHP页面,我正在尝试将一些数据发布到另一个PHP页面并获取数据.
这是我目前拥有的:
<?php
// Initialize cURL session
$ch = curl_init('postpage.php');
// Set some options on the session
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, array('field1' => 'Andrew'));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
// Execute post
$result = curl_exec($ch);
var_dump($result);
// Close the session
curl_close($ch);
?>
Run Code Online (Sandbox Code Playgroud)
并在postpage.php中:
<?php
echo 'Receipt of post request. field1:'.$_POST["field1"];
?>
Run Code Online (Sandbox Code Playgroud)
所有var_dump给我的是:
string(0) ""
Run Code Online (Sandbox Code Playgroud)
为什么我没有收回文字?
谢谢!
| 归档时间: |
|
| 查看次数: |
2669 次 |
| 最近记录: |