[8] ErrorException in Index.php line 23

未定义数组索引: HTTP_USER_AGENT

  1. $this->redirect('http://www.hljwht.gov.cn/index.php/mobile/index/index');
  2. }else{
  3. $this->redirect('http://www.hljwht.gov.cn/index.php/home/index/index');
  4. }
  5. }
  6. public function is_mobile(){
  7. $user_agent = $_SERVER['HTTP_USER_AGENT'];
  8. $mobile_agents = Array("240x320","acer","acoon","acs-","abacho","ahong","airness","alcatel","amoi","android","anywhereyougo.com","applewebkit/525","applewebkit/532","asus","audio","au-mic","avantogo","becker","benq","bilbo","bird","blackberry","blazer","bleu","cdm-","compal","coolpad","danger","dbtel","dopod","elaine","eric","etouch","fly ","fly_","fly-","go.web","goodaccess","gradiente","grundig","haier","hedy","hitachi","htc","huawei","hutchison","inno","ipad","ipaq","ipod","jbrowser","kddi","kgt","kwc","lenovo","lg ","lg2","lg3","lg4","lg5","lg7","lg8","lg9","lg-","lge-","lge9","longcos","maemo","mercator","meridian","micromax","midp","mini","mitsu","mmm","mmp","mobi","mot-","moto","nec-","netfront","newgen","nexian","nf-browser","nintendo","nitro","nokia","nook","novarra","obigo","palm","panasonic","pantech","philips","phone","pg-","playstation","pocket","pt-","qc-","qtek","rover","sagem","sama","samu","sanyo","samsung","sch-","scooter","sec-","sendo","sgh-","sharp","siemens","sie-","softbank","sony","spice","sprint","spv","symbian","tablet","talkabout","tcl-","teleca","telit","tianyu","tim-","toshiba","tsm","up.browser","utec","utstar","verykool","virgin","vk-","voda","voxtel","vx","wap","wellco","wig browser","wii","windows ce","wireless","xda","xde","zte");
  9. $is_mobile = false;
  10. foreach ($mobile_agents as $device) {//这里把值遍历一遍,用于查找是否有上述字符串出现过
  11. if (stristr($user_agent, $device)) { //stristr 查找访客端信息是否在上述数组中,不存在即为PC端。
  12. $is_mobile = true;
  13. break;
  14. }
  15. }

Call Stack

  1. in Index.php line 23
  2. at Error::appError(8, 'Undefined index: HTT...', '/www/wwwroot/118.89....', 23, []) in Index.php line 23
  3. at Index->is_mobile() in Index.php line 13
  4. at Index->index()
  5. at ReflectionMethod->invokeArgs(object(Index), []) in App.php line 232
  6. at App::invokeMethod([object(Index), 'index'], []) in App.php line 397
  7. at App::module(['', null, null], ['app_namespace' => 'app', 'app_debug' => true, 'app_trace' => false, ...], null) in App.php line 140
  8. at App::run() in start.php line 18
  9. at require('/www/wwwroot/118.89....') in index.php line 17

Environment Variables

GET Dataempty
POST Dataempty
Filesempty
Cookiesempty
Sessionempty
Server/Request Data
USER www
HOME /home/www
FCGI_ROLE RESPONDER
SCRIPT_FILENAME /www/wwwroot/118.89.243.46/public/index.php
QUERY_STRING
REQUEST_METHOD GET
CONTENT_TYPE
CONTENT_LENGTH
SCRIPT_NAME /index.php
REQUEST_URI /
DOCUMENT_URI /index.php
DOCUMENT_ROOT /www/wwwroot/118.89.243.46/public
SERVER_PROTOCOL HTTP/1.1
REQUEST_SCHEME http
GATEWAY_INTERFACE CGI/1.1
SERVER_SOFTWARE nginx/1.12.2
REMOTE_ADDR 118.184.84.137
REMOTE_PORT 3270
SERVER_ADDR 172.21.0.11
SERVER_PORT 80
SERVER_NAME 118.89.243.46
REDIRECT_STATUS 200
PATH_INFO
HTTP_HOST www.hljwht.gov.cn
HTTP_ACCEPT */*
HTTP_ACCEPT_ENCODING gzip,deflate
PHP_SELF /index.php
REQUEST_TIME_FLOAT 1526899762.665
REQUEST_TIME 1526899762
Environment Variablesempty
ThinkPHP Constants
APP_PATH /www/wwwroot/118.89.243.46/public/../application/
THINK_VERSION 5.0.3
THINK_START_TIME 1526899762.6656
THINK_START_MEM 258400
EXT .php
DS /
THINK_PATH /www/wwwroot/118.89.243.46/thinkphp/
LIB_PATH /www/wwwroot/118.89.243.46/thinkphp/library/
CORE_PATH /www/wwwroot/118.89.243.46/thinkphp/library/think/
TRAIT_PATH /www/wwwroot/118.89.243.46/thinkphp/library/traits/
ROOT_PATH /www/wwwroot/118.89.243.46/
EXTEND_PATH /www/wwwroot/118.89.243.46/extend/
VENDOR_PATH /www/wwwroot/118.89.243.46/vendor/
RUNTIME_PATH /www/wwwroot/118.89.243.46/runtime/
LOG_PATH /www/wwwroot/118.89.243.46/runtime/log/
CACHE_PATH /www/wwwroot/118.89.243.46/runtime/cache/
TEMP_PATH /www/wwwroot/118.89.243.46/runtime/temp/
CONF_PATH /www/wwwroot/118.89.243.46/public/../application/
CONF_EXT .php
ENV_PREFIX PHP_
IS_CLI false
IS_WIN false