In CLI mode getenv('HOSTNAME') returns HOSTNAME environment variable correctly, but when called in script returns FALSE.
Why? How can I get the HOSTNAME variable in script?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
HOSTNAMEis not a CGI environment variable, hence not present in normal PHP scripts.But you can alternatively use
Or read the system config file:
But most PHP scripts should just use
$_SERVER["SERVER_NAME"]or the client-requested$_SERVER["HTTP_HOST"]