One popular way is to define a constant in the included file:
define ("INCLUDE_OK", true);
and then check each sub-include:
if (!defined("INCLUDE_OK")) die ("This file can't be executed directly");
Alternatively, as @mikerobi says in his remote answer, save the included files in a folder outside the web root.
source
share