【发布时间】:2013-07-06 05:39:23
【问题描述】:
我手上有一个真正的谜..
看下面几行代码..
if (in_array($_SESSION['enemies'][$i], $clones[$j]->defendAgainst)) {
..
}
其中 $_SESSION['enemies'][$i] 是这样的对象:
object(skinhead)#4 (16)
{
["weapon"]=> object(bowieknife)#5 (2)
{ ["name":protected]=> NULL ["damage":protected]=> NULL }
["name"]=> string(8) "skinhead"
["health"]=>string(3) "100"
["strength"]=> string(2) "10"
["luck"]=> string(1) "2"
["money"]=>string(1) "0"
["exp"]=> string(1) "0"
["rank"]=> string(2) "20"
["points"]=> string(1)"0"
["location_id"]=> NULL
["comboAttack"]=> int(2)
["attackValue"]=> int(15)
["attackType"]=> NULL
["attackMessage"]=> string(198) "Enemy #1 pulls off a 2-hit combo.Enemy #1 slashes at you with a bowie knife.You defend.You lose 8 health.Enemy #1 slashes at you with a bowie knife."
["target1"]=> NULL ["target2"]=> NULL }
而 $clones[$j]->defendAgainst 是一个整数数组
现在 in_array 应该评估为 false,因为它正在 int 数组中搜索对象。但相反,它返回真!!!!这怎么可能??????
【问题讨论】:
-
请让您的问题可读。
-
怎么看不懂?....
-
@user2361103:您的对象都在一行中。
-
对象的内容并不是我的问题的重点......重点是对象不是 int,我包含了 var_dump 以强调这一事实......
标签: php