Fsockopen in php imitates post and get

Source: Internet
Author: User
In php, the fsockopen function can simulate the user's access to some websites and also carry some common information. if the browser, IP address, post, get, and other data, next I will introduce you to you separately. if you want to use the fsockopen function... in php, the fsockopen function can simulate the user's access to some websites and also carry some common information. if the browser, IP address, post, get, and other data, next I will introduce you to you separately.

If you want to use the fsockopen function, you must set allow_url_fopen = On to enable in php. ini.

For Example, fsockopen () Example. the code is as follows:

 n";} else {    $out = "GET / HTTP/1.1rn";    $out.= "Host: www.example.comrn";    $out.= "Connection: Closernrn";    fwrite($fp, $out);    while (!feof($fp)) {        echo fgets($fp, 128);    }    fclose($fp);}?>

Forge post and post http requests (URLs) and obtain the returned values. the code is as follows:

 

Brief description: The second line of the code is your IP address or domain name, and the fourth line is the specific address of the page you want to POST. In this example, the content of fsock. php is as follows:

 ";echo "password:" . $_POST['password'];?>
// The result is username: demo password: hahaha.

The code for forging get and post and get methods is as follows:

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.