PHP Simulation Request page Jump problem
I accessed a page through a mock request a.php
Want to implement the function of Automatic request B page in a.php page
Want to ask the automatic request function code How to implement?
------Solution--------------------
/**
* Post method to get data
* @param string $url destination URL
* @param array $dataes the data to post
* @param int $timeout The maximum time to wait for a response defaults to 1
* @return $output Returns the appropriate return if the host is available if it is not valid returns false
*/
static function post ($url, $dataes, $timeout =1) {
$ch = Curl_init ();
curl_setopt ($ch, Curlopt_url, $url);
curl_setopt ($ch, curlopt_returntransfer,1);
Specify data transfer support post
curl_setopt ($ch, curlopt_post,1);
Set the key-value pair for post delivery
curl_setopt ($ch, Curlopt_postfields, $dataes);
Set timeout
curl_setopt ($ch, Curlopt_timeout, $timeout);
$output =curl_exec ($ch);
Curl_close ($ch);
return $output;
}