Posted By

tylerhall on 04/11/07


Tagged

file include


Versions (?)

Who likes this?

10 people have marked this snippet as a favorite

basicmagic
bitcrumb
hudge
vali29
bioascii
jfherring
silentbob84
dantreacy
voove
ringo380


Test if a PHP File Is Being Included


 / Published in: PHP
 

This tests to see if the current file is being included or run directly. It's useful to add to the top of your include files to stop malicious users from accessing them directly in the browser.

  1. if(__FILE__ == $_SERVER['SCRIPT_FILENAME'])
  2. die("This file cannot be executed directly");

Report this snippet  

You need to login to post a comment.