Home > Backend Development > PHP Tutorial > Methods in PHP to prevent direct access or viewing or downloading of the config.php file

Methods in PHP to prevent direct access or viewing or downloading of the config.php file

高洛峰
Release: 2023-03-02 16:18:02
Original
1206 people have browsed it

Or, the design of PHP itself avoids directly viewing the file content? From a security perspective, what protection measures should be taken for this system-level file?
Perfect answer from a netizen
After research, we found the following commonly used methods:

1 Define an identification variable in the program

Copy the code The code is as follows:
define('IN_SYS', TRUE);


2 In config.php Get this variable in
Copy code The code is as follows:
if(!defined('IN_SYS')) {
exit('Access Forbidden');
}

Related labels:
php
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
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template