How does the php language determine the user's access method?
The scenario is as follows:
I want to display different content by determining the user's access method to this address. If accessed through the image src, the image will be displayed. If it is accessed through the image src, the image will be displayed. The browser directly accesses and displays the web page information
Accept can be judged by the Accept header information of the request. The browser request will bring text/html | application/xhtml+xml | application/xml similar information, of which text/html will definitely have it, and the img tag will src will not have text/html request type
You can determine whether the
Referer
in the HTTP request header, that is, the$_SERVER['HTTP_REFERER']
in PHP, is empty.Generally, if it is empty, it means that you can directly enter the image address to open it.
instead of empty is generally opened through the
<img>
tag.Of course the only exception is when this user right-clicks on this
<img>
tag to view the image in a new tab.Add a parameter in the access url, which is used to determine the user's access method. It’s that simple