简体   繁体   中英

PHP undefined index error

Please help me again! I have problems with this code:

<?php
  $pathThemes = INC_DIR . "themes";
  $d = dir($pathThemes);
  while (false !== ($entry = $d->read())) {
    $fileInfo = pathinfo($pathThemes . '/' . $entry);

    if ('php' == $fileInfo['extension']) {
      include_once($pathThemes . '/' . $entry);
      $name = $fileInfo['filename'];
      if (!$GLOBALS['fc_config']['themes'][$name]['name']) {
        unset($GLOBALS['fc_config']['themes'][$name]);
      }
    }
  }
?>

It says me:

Notice: Undefined index: name in C:\\wamp\\www\\FlashChat_v607\\chat\\inc\\include_themes.php on line 10

Notice: Undefined index: name in C:\\wamp\\www\\FlashChat_v607\\chat\\inc\\include_themes.php on line 10

Notice: Undefined index: name in C:\\wamp\\www\\FlashChat_v607\\chat\\inc\\include_themes.php on line 10

Notice: Undefined index: name in C:\\wamp\\www\\FlashChat_v607\\chat\\inc\\include_themes.php on line 10

尝试使用isset($ GLOBALS ['fc_config'] ['themes'] [$ name] ['name'])与

if (!isset($GLOBALS['fc_config']['themes'][$name]['name'])) {

看一下isset函数

Try this:

  if (!empty($name) && isset($GLOBALS['fc_config']['themes'][$name]['name'])) {
    unset($GLOBALS['fc_config']['themes'][$name]);
  }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM