php notice undefined index http_host in $GLOBALS[&

2019-07-18 03:19发布

Suddenly, I'm getting this notice from php after a recent php version update. It is used in several places (particularly my htmlMimeMail class).

Code is: $mail->setSMTPParams('*mail.xxxx.xxx*', 26, $GLOBALS['HTTP_SERVER_VARS']['HTTP_HOST'], 1, '*email-name*', '*email-password*');

The notice is: Undefined index: HTTP_HOST in xxxx on line xxx

The codes seems to be working fine, but the notice is annoying and I expect notices are used for a reason. How can I clear this notice?

标签: php http host
1条回答
戒情不戒烟
2楼-- · 2019-07-18 04:07

$HTTP_SERVER_VARS is deprecated; use $_SERVER:

$mail->setSMTPParams('*mail.xxxx.xxx*', 26, $_SERVER['HTTP_HOST'], 1,
    '*email-name*', '*email-password*');
查看更多
登录 后发表回答