您的位置:首页 > 理论基础 > 计算机网络

php如何通过get方法发送http请求,并且得到返回的参数

2013-11-18 16:48 260 查看
向指定的url发送参数,这是一个跨域访问问题,具体事例如下:
/test.php
<?php
$ch = curl_init();

$str ='http://127.0.0.1/form.php?id=10';
curl_setopt($ch, CURLOPT_URL, $str);
curl_setopt ( $ch, CURLOPT_RETURNTRANSFER, true );
$output = curl_exec($ch);
var_dump( $output );
?>

//页面输出结果  string(2) "10"

//form.php 文件内容如下
<?php
$id = $_GET['id'];
echo $id;
?>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐