[Php]
<? Php
// Fsocket simulate get submission
$ Gurl = "http: // localhost/php/t. php? Uu = gggggg ";
// Print_r (parse_url ($ gurl ));
Echo "The following is the response content in GET mode: <br> ";
Sock_get ($ gurl );
Function sock_get ($ url)
{
$ Info = parse_url ($ url );
$ Fp = fsockopen ($ info ["host"], 80, $ 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. "<br> ";
}
}
// Fsocket simulate post submission
$ Purl = "http: // localhost/php/t. php ";
Echo "The following is the POST Response content: <br> ";
Sock_post ($ purl, "uu = rrrrrrrrrrrr & kk = mmmmmm ");
Function sock_post ($ url, $ query)
{
$ Info = parse_url ($ url );
$ Fp = fsockopen ($ info ["host"], 80, $ 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. "<br> ";
}
}
?>
Request Response page t. php
[Php]
<? Php
If (isset ($ _ GET ['uu ']) {
Echo '<font color = "red"> t. the value of $ _ GET ["uu"] in php is :'. $ _ GET ['uu ']. "</font> <br> ";
}
If (isset ($ _ POST ['uu ']) {
Echo '<font color = "red"> the value of $ _ POST in t. php is: </font> <br> ';
Print_r ($ _ POST );
}
?>
The running result is as follows:
The following is the result of Firebug Viewing:
By Fanteathy