Home  >  Article  >  Backend Development  >  php 模拟请求 页面跳转有关问题

php 模拟请求 页面跳转有关问题

WBOY
WBOYOriginal
2016-06-13 11:50:48705browse

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

想请教下 自动请求功能代码怎么实现?
------解决方案--------------------

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

Statement:
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