Saturday, February 12, 2011

Is there a PHP function or variable giving the local host name?

When a script runs under Apache, I insert $_SERVER['SERVER_NAME'] value into an error reporting e-mail message.

However, if a Web script forks a "worker" job with nohup php ..., $_SERVER['SERVER_NAME'] appears to be empty there. Thus, if an error occurs, it's reported without a host name.

Can I reliably get the host name by means of PHP, without calling Unix hostname command?

0 comments:

Post a Comment