Home > php教程 > php手册 > body text

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

WBOY
Release: 2016-06-13 11:59:33
Original
933 people have browsed it

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

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

复制代码 代码如下:


define('IN_SYS', TRUE);



2 在config.php中获取这变量

复制代码 代码如下:


if(!defined('IN_SYS')) {
exit('禁止访问');
}

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 Recommendations
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!