×
Home About Us Products Services News Free Scripts Contact
news php scripts and software

PHP example - How to ensure that a PHP file can not be executed directly but just included?


PHP - How to ensure that a PHP file can not be executed directly but just included?

This technique could be useful if you have some files to be included, and you wish to prevent that they are executed directly by placing their address in the web browser etc.

You need to add the following lines at the begining of your PHP script:

<?php 
if ($_SERVER['REQUEST_URI'] == $_SERVER['PHP_SELF']) 
    die("A message ..."); 
 
...
 
?>

Category: PHP

 
<< Go back