hyperlink - Protect a PHP file to include before opening by other people -


i'm working on small php project. want include many php files, want protect them before opening via directlink other people.

for example:

<?php include 'content/scripts/php/sample.php'; ?> 

i don't want people access sample.php via

http://samplepage.com/content/scripts/php/sample.php 

if in shared hosting , can't place files outside web server folder or can't use .htaccess common method define constant in main php file , check constant @ top of each included file , die() if not defined. in way people can still access file path see blank page. wordpress uses approach example.

in main php file:

define('app', true); 

in included files:

if(!defined('app')) die(); 

Comments

Popular posts from this blog

php - Submit Form Data without Reloading page -

linux - Rails running on virtual machine in Windows -

php - $params->set Array between square bracket -