当我从命令行运行我的
PHP脚本时,我收到以下通知.我假设原因是这些变量如SERVER_NAME在没有浏览器的情况下运行时不适用.
原文链接:/php/139257.html在我的代码中,如何检测它是从命令行运行并跳过这些行,所以我不必看到这些通知?
我不想通过管道到/ dev / null阻止这些通知,我宁愿增强PHP代码.
david@ubuntu:/var/www/user$PHP cron_email.PHP PHP Deprecated: Comments starting with '#' are deprecated in /etc/PHP5/cli/conf.d/mcrypt.ini on line 1 in Unknown on line 0 PHP Notice: Undefined index: SERVER_NAME in /var/www/user/codestart.PHP on line 14 PHP Notice: Undefined index: REMOTE_ADDR in /var/www/user/codestart.PHP on line 97 PHP Notice: Undefined index: REQUEST_URI in /var/www/user/codestart.PHP on line 99 PHP Notice: Undefined index: HTTP_REFERER in /var/www/user/codestart.PHP on line 100 PHP Notice: Undefined index: REQUEST_METHOD in /var/www/user/codestart.PHP on line 101 PHP Notice: Undefined index: HTTP_USER_AGENT in /var/www/user/codestart.PHP on line 102