What is the concept of "Include guard" in PHP and how can it be used to prevent direct script access?
The concept of "Include guard" in PHP involves using conditional statements to check if a specific constant is defined before including a file. This technique helps prevent direct script access by ensuring that the file is only included if it is being accessed through the intended entry point.
<?php
define('INCLUDED', true);
if (!defined('INCLUDED')) {
header('HTTP/1.0 403 Forbidden');
exit;
}
// Rest of the PHP code goes here
?>