Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 360
  • Last Modified:

if statement if (!empty

would it be correct to write it like this?
if (!empty($value1)) || (!empty($value2)) || (!empty($value3)) || (!empty($value4))
0
Braveheartli
Asked:
Braveheartli
1 Solution
 
DangerousJeffCommented:
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

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now