It can happen that a function is only callable from one interface (console, apache…). There is a function that returns exactly what we are looking for.
In the following example, we are looking to know whether the call is from the console.
if (php_sapi_name()!"cli")
header ("Location: http://www.sadtrombone.com/");
die(;
}