Answer the question
In order to leave comments, you need to log in
How to correctly check and prevent the file from executing during a direct call?
Let's say I put function files in the libs folder and include them in several pages. But how to check that the access to these files was direct (for example, site.ru/libs/functions.php) and prohibit their execution outside the connection in other files?
Answer the question
In order to leave comments, you need to log in
Well, the usual way is to define a variable of type $access = true in index, and check in the included file:if (!isset($access) || !$access) exit();
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question