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

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

WBOY
WBOYOriginal
2016-05-17 09:10:291125browse

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

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

复制代码 代码如下:

define('IN_SYS', TRUE);


2 在config.php中获取这变量
复制代码 代码如下:

if(!defined('IN_SYS')) {
exit('禁止访问');
}
Statement:
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