if statement if (!empty

would it be correct to write it like this?
if (!empty($value1)) || (!empty($value2)) || (!empty($value3)) || (!empty($value4))
LVL 1
BraveheartliMarketingAsked:
Who is Participating?
 
DangerousJeffConnect With a Mentor Commented:
You are best off putting parenthesis round the whole if statement

if ((!empty($value1)) || 
    (!empty($value2)) || 
    (!empty($value3)) || 
    (!empty($value4)))

Open in new window

0
 
BraveheartliMarketingAuthor Commented:
thank you
0
 
Beverley PortlockCommented:
Are you sure you mean || and not && ? I've noticed that people often invert their logic when NOT conditions turn up. Your IF will be true if any of them are non-empty.
0
All Courses

From novice to tech pro — start learning today.