Home >Backend Development >PHP Tutorial >The php function get_headers is a HEAD request or a GET request

The php function get_headers is a HEAD request or a GET request

WBOY
WBOYOriginal
2016-07-25 08:55:131486browse
  1. $imageurl = 'http://127.0.0.1/1.png';
  2. $headers = get_headers($imageurl);
Copy the code

In fact, the picture is also a local picture. But it is indeed "remote", and remote pictures can also be understood as pictures of URL addresses.

Use the packet capture tool tcpdump to listen to the local port 80:

  1. sudo tcpdump -i lo -nnA 'src port 80'
Copy the code

Then visit test.php, the screenshot of the key part of the captured package is as follows: The php function get_headers is a HEAD request or a GET request You can see that the content of the picture has also been requested back.

It is finally determined that get_headers is a GET request. If you want to initiate a HEAD request, you can use fsockopen or curl.

Test code download (including pictures): test code for php function get_headers



Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn