简体   繁体   English

PHP未定义索引错误

[英]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 注意:未定义的索引:第10行上的C:\\ wamp \\ www \\ FlashChat_v607 \\ chat \\ inc \\ include_themes.php中的名称

Notice: Undefined index: name in C:\\wamp\\www\\FlashChat_v607\\chat\\inc\\include_themes.php on line 10 注意:未定义的索引:第10行上的C:\\ wamp \\ www \\ FlashChat_v607 \\ chat \\ inc \\ include_themes.php中的名称

Notice: Undefined index: name in C:\\wamp\\www\\FlashChat_v607\\chat\\inc\\include_themes.php on line 10 注意:未定义的索引:第10行上的C:\\ wamp \\ www \\ FlashChat_v607 \\ chat \\ inc \\ include_themes.php中的名称

Notice: Undefined index: name in C:\\wamp\\www\\FlashChat_v607\\chat\\inc\\include_themes.php on line 10 注意:未定义的索引:第10行上的C:\\ wamp \\ www \\ FlashChat_v607 \\ chat \\ inc \\ include_themes.php中的名称

尝试使用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]);
  }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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