Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在制作自己的 MVC 框架,我记得在 phpBB 论坛索引页面代码中看到过类似的内容:
define('IN_PHPBB', true);
然后在只包含而不是直接访问的文件中,它在顶部有这个:
if(!defined('IN_PHPBB')) { die(); }
我想知道这是否是必要的,尤其是对于类文件,因为如果直接访问它们,它们将不会运行,因为它们没有被实例化。
我建议您将文件 .htaccess 与指令拒绝从所有文件夹中放入您的 php 类文件。官方文档在这里