search

Home  >  Q&A  >  body text

How does PHP determine the user's access method, whether it is accessed by the src of the image?

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

巴扎黑巴扎黑2823 days ago738

reply all(3)I'll reply

  • 漂亮男人

    漂亮男人2017-06-05 11:10:06

    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

    reply
    0
  • ringa_lee

    ringa_lee2017-06-05 11:10:06

    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.

    reply
    0
  • phpcn_u1582

    phpcn_u15822017-06-05 11:10:06

    Add a parameter in the access url, which is used to determine the user's access method. It’s that simple

    reply
    0
  • Cancelreply