Fatal error: Cannot use string offset as an array in …错误原因和解决
2008/09/03 02:13 ArthurXF
<?php
echo 'PHP VERSION:'.PHP_VERSION;
echo '<br />';
$a = 'abc';
$example = 1;
if($example == 1) {
unset($a[0]); // Fatal error: Cannot unset string offsets in
} elseif($example == 2) {
$b = $a[0][0]; // Fatal error: Cannot use string offset as an array in …
}
?>
echo 'PHP VERSION:'.PHP_VERSION;
echo '<br />';
$a = 'abc';
$example = 1;
if($example == 1) {
unset($a[0]); // Fatal error: Cannot unset string offsets in
} elseif($example == 2) {
$b = $a[0][0]; // Fatal error: Cannot use string offset as an array in …
}
?>
这个故障偶尔程序员会犯,尤其是 例子2这种无效赋值。