PHP include or standalone

A

Anonymous

Guest
Hello.

Does somebody know how could PHP recognize whether it is included (or required) or called standalone?
 
In the main file that includes the file, you put:

Code:
define('__INCLUDED__', true);

in the included file you put:
Code:
if ( defined('__INCLUDED__') )
{
    // included
}

else
{
    // standalone
}


Oh yeah :)
 
Please use the code tags as i start getting tired of editing all the posts.

if you will use <? or <?php in the code it will get syntax highlighted as well..
 
Back
Top