If you are executing it from the command line, and perhaps passing parameters to the script, you should check if $argv contains something (that is the array containing the command line parameters).
Also, you could check for environment variables, and see one of the several associated w/ the server is set.
HTH