Home >Backend Development >PHP Problem >How to disable iframe code in php
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.
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!