I need to determine whether the PHP file is being loaded via cron or command line within the code. How can I do this?
This is one simple way. Certain elements of the $_SERVER array are only set if called from HTTP. Thus you can:
$_SERVER
if(!isset($_SERVER['REQUEST_METHOD'])){ // from cron or command line }else{ // from HTTP }
Others include: $_SERVER['HTTP_HOST']
$_SERVER['HTTP_HOST']