Prevent direct access to a php include file
Add this to the page that you want to only be included <?php if(!defined(‘MyConst’)) { die(‘Direct access not permitted’); } ?> then on the pages that include it add <?php define(‘MyConst’, TRUE); ?>
Add this to the page that you want to only be included <?php if(!defined(‘MyConst’)) { die(‘Direct access not permitted’); } ?> then on the pages that include it add <?php define(‘MyConst’, TRUE); ?>
FIRST QUESTION: Why aren’t include guards protecting my header files from mutual, recursive inclusion? They are. What they are not helping with is dependencies between the definitions of data structures in mutually-including headers. To see what this means, let’s start with a basic scenario and see why include guards do help with mutual inclusions. Suppose … Read more