php如何发送get或者post请求????

xuxiaoping_cumt 2005-12-27 08:33:34
php如何发送get或者post请求

比如我现在要向localhost/webcounter/reinform.aspx发送一个post请求应该如何做呢
我用如下代码
$target="/webcounter/ReInform.aspx";//目标文件URL
$domain="localhost";//网站域名
$post_data="uid=3&webSiteID=1®UserName=dd®Time=2005-4-7 15:45:44®Ip=127.0.0.1®Os=ddklf®Browser=dfdf&ac=dddd";//传递的数据
$fp=fsockopen($domain,80);
$out = "GET ".$target."?".$post_data." HTTP/1.1\r\n";
$out .= "Host: localhost\r\n";

fwrite($fp, $out);
while (!feof($fp)) {
echo fgets($fp, 128);
}
fclose($fp);
运行老是提示我
这个东西

HTTP/1.1 400 Bad Request Content-Type: text/html Date: Tue, 27 Dec 2005 12:25:17 GMT Connection: close Content-Length: 20
Bad Request

郁闷死了 高手教教偶哈
...全文
81 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

21,887

社区成员

发帖
与我相关
我的任务
社区描述
从PHP安装配置,PHP入门,PHP基础到PHP应用
社区管理员
  • 基础编程社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧