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

Publicités

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: http://www.sadtrombone.com/");
   die(;
}
Publicités

Leave a Reply