简体   繁体   中英

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:

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.

I suggest to you to put a file .htaccess with with the directive deny from all inside the folder with your php class files. The official documentation is here

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM