PHP – How to find the origin of the call on a PHP function


It can happen that a function is only called from an interface (console, apache …). There is a function that returns exactly what we are looking for.

In the following example, we look at whether the call is from the console.

if (php_sapi_name()!"cli")
   header ("Location:");

Leave a Reply