Hier ein Beispiel, wie man eine php-Datei davor schützen kann, dass der Programmcode ausgeführt wird, wenn die Datei direkt vom Client aus aufgerufen wird:
<?php
/**
* Protect against direct calls from web clients
*/
if(1 == count(get_included_files())) {
http_response_code(403);
die(
'<style>h1 { font-size: 120%; margin-bottom: 0; } p { margin-top: 0;}</style>'
. '<h1>403 Forbidden</h1><p>Access to this resource is not permitted.</p>'
);
}
// My library code here
?>