Home >Backend Development >PHP Problem >How to disable iframe code in php

How to disable iframe code in php

藏色散人
藏色散人Original
2020-08-17 10:31:573015browse

In PHP, you can use the "header('X-Frame-Options:Deny');" method to prohibit the iframe frame code, where the parameter "DENY" means that the page is not allowed to be displayed in the frame, even in Nesting within pages of the same domain name is also not allowed.

How to disable iframe code in php

Recommended: "PHP Video Tutorial"

php prohibits iframe frame code and prohibits pages from being iframed

A simple code can be achieved:

header('X-Frame-Options:Deny');

Use X-Frame-Options which has three values:

DENY

means that the page does not It is allowed to be displayed in a frame, even if it is nested in pages with the same domain name, it is not allowed.

SAMEORIGIN

means that the page can be displayed in the frame of the same domain name page.

ALLOW-FROM uri

indicates that the page can be displayed in the frame from the specified source.

In other words, if it is set to DENY, it will not only fail to load when embedded in other people's website frames, but will also fail to load in pages with the same domain name. On the other hand, if set to SAMEORIGIN, the page can be nested in the frame of the page with the same domain name.

The above is the detailed content of How to disable iframe code in php. For more information, please follow other related articles on the PHP Chinese website!

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