
How to prevent others from directly accessing php files
You can judge whether a certain constant is defined or whether the defined value is the same. If it is not If the definition or value is different, the script will stop running.
defined('IS_ALLOW') or die('禁止访问!');
Access result: Access prohibited!
If you need to reference it in other php files, you can define the constant first and then reference it.
A.php
defined('IS_ALLOW') or die('禁止'); echo "访问成功!";
B.php
define('IS_ALLOW', true); require './A.php';
Result of accessing B.php: Access successful!
The above is the detailed content of How to prevent others from directly accessing php files. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undress AI Tool
Undress images for free

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SublimeText3 Chinese version
Chinese version, very easy to use

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

WebStorm Mac version
Useful JavaScript development tools

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function






