[英]Prevent people from accessing your classes and include files directly
I'm making my own MVC framework and I remember seeing something like this in phpBB forums index page code: 我正在制作自己的MVC框架,并且记得在phpBB论坛索引页面代码中看到了类似的内容:
define('IN_PHPBB', true);
and then in the files that are only ment to be included and not directly accessed it has this at the top: 然后在仅包含但不直接访问的文件中,其顶部为:
if(!defined('IN_PHPBB')) {
die();
}
I was wondering if that is neccessary especially with class files because if they are directly accessed they won't run anyway since they were not instantiated. 我想知道这是否是必需的,尤其是对于类文件,因为如果直接访问它们,它们将不会运行,因为它们没有被实例化。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.