【发布时间】:2015-09-03 18:18:27
【问题描述】:
在我的 php 应用程序中,我有以下代码:
try {
$ordersIngredients[$userIngredient->getId()][$day] += $quantity;
} catch (\Exception $e) {
~r(array(
$ordersIngredients[$userIngredient->getId()],
$day,
array_key_exists($day, $ordersIngredients[$userIngredient->getId()]),
$e->getMessage()
));
}
r() 函数打印以下内容:
array(4)
0 => array(4)
0 => 0.9
1 => null
2 => null
3 => 1
)
1 => 3
2 => true
3 => Notice: Undefined offset: 3
)
考虑到数组的转储和array_key_exists,当偏移量实际存在时,我怎么能在未定义的偏移量上出现错误?
【问题讨论】:
-
旁注:你怎么会有一个以
~开头的函数名? -
@phpisuber01:不属于名称php.net/manual/en/language.operators.bitwise.php
-
~r (REF) 是一个倾倒东西的库
-
你的
catch是怎么发现的?这是notice不是异常/错误。 -
@RocketHazmat 也许他定义了一个自定义错误处理程序,如stackoverflow.com/questions/5373780/…