php文件里如何以get方式向远程URL

y365y 2009-10-30 10:01:09
请问在flow.php文件中如何以get方式向远程URL(如http://www.site.com/url.php?user=xxx&time=XXX)提交请求
不能用JS,只能在PHP中处理
...全文
115 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
lvhong84 2009-10-31
  • 打赏
  • 举报
回复
用 curl
骄傲青蛙 2009-10-31
  • 打赏
  • 举报
回复


<?php
// Create a stream
$opts = array(
'http'=>array(
'method'=>"GET",
'header'=>"Accept-language: en\r\n" .
"Cookie: foo=bar\r\n"
)
);

$context = stream_context_create($opts);

// Open the file using the HTTP headers set above
$file = file_get_contents('http://www.site.com/url.php?user=xxx&time=XXX', false, $context);
?>

//$file是你用get请求的结果, 没有值时为false
骄傲青蛙 2009-10-31
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 mrshelly 的回复:]
PHP code<?phpvar_dump(file_get_contents('http://www.site.com/url.php?user=xxx&time=XXX'));?>
[/Quote]

file_get_contents('http://www.site.com/url.php?user=xxx&time=XXX')
//返回请求结果

var_dump()
//打印出结果

knight0450 2009-10-31
  • 打赏
  • 举报
回复
根据file_get_contents()返回的值去判断~~
$flag = file_get_contents();
tony-杨 2009-10-31
  • 打赏
  • 举报
回复
方法多了
1、用file或file_get_contents等
2、用CURL系列的函数
3、用Socket系列函数
4、用fsockopen
dhgdmw 2009-10-31
  • 打赏
  • 举报
回复
马个克
fxs_2008 2009-10-30
  • 打赏
  • 举报
回复
可以的
y365y 2009-10-30
  • 打赏
  • 举报
回复
如果用楼上的,可以接收返回值吗,因为要通过返回值判断是否提交成功
mrshelly 2009-10-30
  • 打赏
  • 举报
回复


<?php
var_dump(file_get_contents('http://www.site.com/url.php?user=xxx&time=XXX'));
?>

21,891

社区成员

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

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