Home > Backend Development > PHP Tutorial > php 模拟请求 页面跳转问题

php 模拟请求 页面跳转问题

WBOY
Release: 2016-06-23 14:00:56
Original
983 people have browsed it

我通过模拟请求访问了一个页面A.php
想A.php 页面里实现自动请求B页面的功能

想请教下 自动请求功能代码怎么实现?


回复讨论(解决方案)

查看curl函数

查看curl函数

本人PHP新手,能不能详细点呢?谢谢了!

/**	 * post方式获取数据	 * @param string $url 目标url	 * @param array $dataes 要post的数据	 * @param int $timeout 等待响应的最大时间  默认为1	 * @return $output 如果host可用就返回相应的返回内容      如果不合法则返回false	 */	static function post($url,$dataes,$timeout=1){		$ch = curl_init();		curl_setopt($ch,CURLOPT_URL,$url);		curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);		//指定数据传输支持post		curl_setopt($ch,CURLOPT_POST,1);		//设置post传递的键值对		curl_setopt($ch,CURLOPT_POSTFIELDS,$dataes);		//设置超时		curl_setopt($ch,CURLOPT_TIMEOUT,$timeout);		$output=curl_exec($ch);		curl_close($ch);		return $output;	}
Copy after login

好像能用,返回信息了!!

source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template