In each of the other files, add these codes at the top.
if (basename($_SERVER[‘PHP_SELF’]) === basename(__FILE__)) {
header($_SERVER[“SERVER_PROTOCOL”] . ” 404 Not Found”);
exit;
}
basename($_SERVER[“PHP_SELF”]) will give you the current filename, and
basename(__FILE__) will give you the name of file it is being called from.
This approach has the advantage that you don’t need to define constant variable in files that will include the “include-only” files (no need for define(“INCLUDING”, true); each time you include).
