Here is 4 best methods to prevent access to your php file directly  <?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/ <?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/ <?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/ <?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/