Home > Backend Development > PHP Tutorial > PHP中防止直接访问或查看或下载config.php文件的方法_PHP

PHP中防止直接访问或查看或下载config.php文件的方法_PHP

WBOY
Release: 2016-06-01 12:10:41
Original
871 people have browsed it

或是,PHP的设计本身就避免直接查看文件内容的情况? 从安全角度考虑,这个系统级的文件应该做什么保护措施?
网友完善的答案
经调研,得出以下常用方法:

1 在程序中定义一个标识变量

复制代码 代码如下:
define('IN_SYS', TRUE);


2 在config.php中获取这变量
复制代码 代码如下:
if(!defined('IN_SYS')) {
exit('禁止访问');
}

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