[PHP]
Fsocket Analog Get Commit
$gurl = "HTTP://LOCALHOST/PHP/T.PHP?UU=GGGGGG";
Print_r (Parse_url ($gurl));
echo "The following is the response content of the Get method:
";
Sock_get ($gurl);
function Sock_get ($url)
{
$info = Parse_url ($url);
$fp = Fsockopen ($info ["host"], $errno, $ERRSTR, 3);
$head = "GET". $info [' Path ']. "?". $info ["Query"]. " Http/1.0\r\n ";
$head. = "Host:". $info [' Host ']. " \ r \ n ";
$head. = "\ r \ n";
$write = fputs ($fp, $head);
while (!feof ($FP))
{
$line = fgets ($FP);
echo $line. "
";
}
}
Fsocket Analog Post Submission
$purl = "http://localhost/php/t.php";
echo "The following is the response of the Post method:
";
Sock_post ($purl, "uu=rrrrrrrrrrrr&&kk=mmmmmm");
function Sock_post ($url, $query)
{
$info = Parse_url ($url);
$fp = Fsockopen ($info ["host"], $errno, $ERRSTR, 3);
$head = "POST". $info [' Path ']. " Http/1.0\r\n ";
$head. = "Host:". $info [' Host ']. " \ r \ n ";
$head. = "referer:http://". $info [' Host ']. $info [' Path ']. \ r \ n ";
$head. = "content-type:application/x-www-form-urlencoded\r\n";
$head. = "Content-length:". strlen (Trim ($query)). " \ r \ n ";
$head. = "\ r \ n";
$head. = Trim ($query);
$write = fputs ($fp, $head);
while (!feof ($FP))
{
$line = fgets ($FP);
echo $line. "
";
}
}
?>
Response page for request t.php
[PHP]
if (Isset ($_get[' UU ')) {
The value of $_get["UU" in Echo ' t.php is: '. $_get[' UU ']. "
";
}
if (Isset ($_post[' UU ')) {
The value of $_post in Echo ' t.php is:
';
Print_r ($_post);
}
?>
The following is the result of the operation:
The following are the results of Firebug's view:
Author: fanteathy
http://www.bkjia.com/PHPjc/478114.html www.bkjia.com true http://www.bkjia.com/PHPjc/478114.html techarticle [PHP]? PHP//fsocket analog Get commit $gurl = HTTP://LOCALHOST/PHP/T.PHP?UU=GGGGGG;//print_r (Parse_url ($gurl)); Echo The following is the response content of the Get mode: BR; Sock_get ($gurl); Functio ...