PHP 注意:未定义的偏移量:同一行中的 0、1、2、3
PHP Notice: Undefined offset: 0, 1, 2,3 in same line
我收到这个 PHP 错误:
Notice: Undefined offset: 0 in D:\MYBLOG\InstantWP_4.3.1\iwpserver\htdocs\wordpress\wp-content\themes\MYBLOG\admin\library\engines\typography-engine.php on line 32
Notice: Undefined offset: 1 in D:\MYBLOG\InstantWP_4.3.1\iwpserver\htdocs\wordpress\wp-content\themes\MYBLOG\admin\library\engines\typography-engine.php on line 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] 如果它被评估为假(空,零,空字符串,...)它就好了。
我收到这个 PHP 错误:
Notice: Undefined offset: 0 in D:\MYBLOG\InstantWP_4.3.1\iwpserver\htdocs\wordpress\wp-content\themes\MYBLOG\admin\library\engines\typography-engine.php on line 32
Notice: Undefined offset: 1 in D:\MYBLOG\InstantWP_4.3.1\iwpserver\htdocs\wordpress\wp-content\themes\MYBLOG\admin\library\engines\typography-engine.php on line 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] 如果它被评估为假(空,零,空字符串,...)它就好了。