Here is 4 best methods to prevent access to your php file directly

  1.  <?php if(count(get_included_files()) ==1) exit(“Error , Contact [email protected]”); echo “data here” ; ?> – See more at: http://www.vishvendrasingh.com/here-is-4-best-methods-to-prevent-access-to-your-php-file-directly/
  2. <?php debug_backtrace() || die (“Direct access not permitted”); echo “data here” ; ?> – See more at: http://www.vishvendrasingh.com/here-is-4-best-methods-to-prevent-access-to-your-php-file-directly/
  3. <?php if (strpos($_SERVER[‘REQUEST_URI’], basename(__FILE__)) !== false) {die(‘Error , Contact [email protected]’);} echo “data here” ; ?> – See more at: http://www.vishvendrasingh.com/here-is-4-best-methods-to-prevent-access-to-your-php-file-directly/
  4. <?php if (basename($_SERVER[‘PHP_SELF’]) == basename(__FILE__)) { die(‘Error , Contact [email protected]’); }; echo “data here” ; ?> – See more at: http://www.vishvendrasingh.com/here-is-4-best-methods-to-prevent-access-to-your-php-file-directly/