What is the correct to allow a PHP file only to be executed if it is included in another PHP file?
For example, let's say I have my main application file "main.php". This file includes "settings.php" as such:
// www.mydomain.com/MAIN.PHP
<?php
require 'settings.php';
?>
// www.mydomain.com/SETTINGS.PHP
<?php
// DO SOMETHING
?>
How can I precent "settings.php" from being executed if a user runs "www.mydomain.com/SETTINGS.PHP" from their browser?
I'm looking for a PHP-Only solution.