PHP 注意:未定义的偏移量:0、1、2、3 在同一行中


PHP Notice: Undefined offset: 0, 1, 2,3 in same line

我收到这个PHP错误:

注意:未定义的偏移量:0 在 D:''MYBLOG''InstantWP_4.3.1''iwpserver''htdocs''wordpress''wp-content''themes''MYBLOG''admin''library''engines''typography-engine.php 在第 32 行

注意:未定义的偏移量:1 in D:''MYBLOG''InstantWP_4.3.1''iwpserver''htdocs''wordpress''wp-content''themes''MYBLOG''admin''library''engines''typography-engine.php在第32行

这是抛出它的 PHP 代码:

/* Check stored against current to make sure we don't display deleted css */
if(is_array($custom_fonts)):
    foreach($custom_fonts as $id => $font):
        if(!$current_custom[$id])unset($custom_fonts[$id]);
    endforeach;
endif;    
$css = '';

第 32 行在这里:

   if(!$current_custom[$id])unset($custom_fonts[$id]);

此错误是什么意思?导致此错误的原因是什么?有没有快速修复来解决这些错误的方法?真的很感谢任何帮助

谢谢

32 行替换为:

if(empty($current_custom[$id]) || !$current_custom[$id])unset($custom_fonts[$id]);

没有真正的问题,只有一个通知(=建议,不是错误,不是警告(,它告诉您$id实际上并不存在于$current_custom数组中。当编码尝试取消 $current_custom[$id] 如果它被评估为 false(null、零、空字符串等(,那就没问题了。