0
這裏對我來說很奇怪。Php邏輯表達式和對象
代碼1:
if($city = Cities::find_by_id($city_id)) {
var_dump($city);
}
這返回:對象(城市)#6(7){...},普通
代碼2:
if($city = Cities::find_by_id($city_id) && $building = Buildings::find_by_id($building_id)) {
var_dump($city);
}
這將返回:布爾(真),我期待的結果像之前那樣
有人可以向我解釋發生了什麼?
'$ var = Object'指定Object到'$ var',但是'$ var = Object && Object'指定了Object && Object'的布爾值評估 –