如何检查OR
语句中是否存在属性,然后检查IF
语句中是否设置了属性?
@if($counsellingSession->has_session_begun == 1 || !empty($thread->close_session == 1))
disabled
@elseif($loop->index > 7 && $data->payment_type == 'free')
disabled
@endif
答案 0 :(得分:3)
尝试property_exist php函数(如果存在)将为您提供true其他明智的false
property_exist($thread,'close_session')
了解property_exist
答案 1 :(得分:1)
也许使用isset
?它将检查对象是否存在或值为空
@if(isset($thread->close_session) && $thread->close_session == 1)
@endif
答案 2 :(得分:1)
您可以使用property_exists
吗?
例如:
@if((property_exists($counsellingSession,"has_session_begun") && $counsellingSession->has_session_begun == 1) || (property_exists($thread,"close_session") && $thread->close_session == 1 ) )
disabled
@elseif($loop->index > 7 && $data->payment_type == 'free')
disabled
@endif