How to Disallow Direct Access to a File with PHP

0

By : Josh Stauffer

Just include this PHP code at the top of your include file.

<?php
if (!empty($_SERVER['SCRIPT_FILENAME']) && 'includefilename.php' == basename($_SERVER['SCRIPT_FILENAME']))
	die ('Direct File Access Prohibited');
?>