How to disable iframe code in php

藏色散人
Release: 2023-03-04 15:52:02
Original
2945 people have browsed it

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');
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!