Copy Code code as follows:
<?php
function Http_open ($url, $data, $cookie = null, $method = "get", $timeout = 60) {
$options = Array ();
$options [' http '] [' method '] = $method;
$options [' http '] [' user_agent '] = $_server[' http_user_agent '];
$options [' http '] [' timeout '] = $timeout;
if ($method = = "POST"):
$length = strlen ($data);
$options [' http '] [' header '] = ' content-type:application/x-www-form-urlencoded\r\n '.
"Content-length: {$length}\r\n".
"P3p:cp=\" cura ADMa DEVa Psao psdo We bus UNI PUR INT DEM STA PRE COM NAV OTC NOI DSP cor\ "\ r \ n".
"Cookie: {$cookie}\r\n".
"Connection:close\r\n";
$options [' http '] [' content '] = $data;
Else
$options [' http '] [' header '] = ' content-type:application/x-www-form-urlencoded\r\n '.
"P3p:cp=\" cura ADMa DEVa Psao psdo We bus UNI PUR INT DEM STA PRE COM NAV OTC NOI DSP cor\ "\ r \ n".
"Cookie: {$cookie}\r\n".
"Connection:close\r\n";
endif
$context = Stream_context_create ($options);
Return file_get_contents ($url, 0, $context);
}
Echo Http_open ("http://localhost/1.php", "Username=haowei", "id=5", "POST");