我正在开发一个网站,看起来不错。然后我打开调试以查看是否有任何错误,并收到以下消息:
Notice: Undefined offset: 0 in I:\path\to\file\MyFile.class.php on line 105
Run Code Online (Sandbox Code Playgroud)
在该行中,您将找到以下代码:
$result = $stmt->fetchAll(PDO::FETCH_ASSOC);
return $result[0]; // line 105
Run Code Online (Sandbox Code Playgroud)
如果我做一个print_r(result)我得到以下结果:
Array (
[0] => Array (
[id] => 3721
[parentID] =>
)
)
Array (
)
Run Code Online (Sandbox Code Playgroud)
如您所见,结果包含两个数组。第一个有数据,第二个没有数据。我从未见过print_r像这样输出两个数组。我猜这是第二个给我带来问题的。
谁能告诉我为什么第二个阵列潜入?
VAR转储
array
0 =>
array
'id' => string '3721' (length=4)
'parentID' => null
array
empty
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1604 次 |
| 最近记录: |