I've noticed that some PHP coders put a routine at the top of their code that is used in an include, which validates whether a variable has been defined, and if it isn't stops processing.
Example, in main.php they will write define('IN_APP',true); they may then have an include such as include('include_file.php').
Then at the beginning of 'include_file.php' they might have...
- Code: Select all
if ( !defined('IN_APP') )
{
die("Hacking attempt");
}
Why is this important? Is this a common practice, and one I should be incorporating each time I use an include?
Lastly, should my include files all have php extensions? I had written some that I saved as txt files (even though I knew they had php code in them). My thinking was that I didn't want them to execute unless they were part of (i.e. included from) a php page.
Way sorry for the length and multipart nature of the question.
Many thanks in advance!
-APS




i had to go through it to understand where to make those changes most of you know about
