Php cleverly obtains server information

Source: Internet
Author: User
How can I obtain server information in PHP mode? In fact, you only need three pieces of code to easily obtain the information about a file on the peer end and the site information.

How can I obtain server information in PHP mode? In fact, you only need three lines of code to easily obtain the information about a file on the peer end and the information about the website to which the file belongs. The code is as follows:

Php

$ Fp = fopen ("http: // www. ***. com /***. htm "," r "); // open files under a site in read-only mode

Foreach ($ http_response_header as $ info) // traverse the file information header of $ http_response_header

Echo $ info ."
"; // Finally output the information of each record

?>

In the information header, the content displayed includes whether the file exists, the file size, file type, and encoding method, you can even obtain the server name and version number used by the site. If you open files such as ASP or PHP, additional information is contained.


Simpler method
$ Fp = fopen ("http: // www. ***. com /***. htm "," r "); // open files under a site in read-only mode
 
Print_r (stream_get_meta_data ($ fp ));

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.