What is the easiest way to use the HEAD command of HTTP in PHP?

前端 未结 5 651
轻奢々
轻奢々 2020-12-03 11:31

I would like to send the HEAD command of the Hypertext Transfer Protocol to a server in PHP to retrieve the header, but not the content or a URL. How do I do this in an effi

5条回答
  •  独厮守ぢ
    2020-12-03 11:46

    Even easier than curl - just use the PHPget_headers()function which returns an array of all header info for any URL you specify. And another real easy way to check for remote file existence is to usefopen()and try to open the URL in read mode (you'll need to enable allow_url_fopen for this).

    Just check out the PHP manual for these functions, it's all in there.

提交回复
热议问题