Solved

if statement if (!empty

Posted on 2011-02-14
3
357 Views
Last Modified: 2012-05-11
would it be correct to write it like this?
if (!empty($value1)) || (!empty($value2)) || (!empty($value3)) || (!empty($value4))
0
Comment
Question by:Braveheartli
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 4

Accepted Solution

by:
DangerousJeff earned 500 total points
ID: 34886868
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
 
LVL 1

Author Closing Comment

by:Braveheartli
ID: 34887014
thank you
0
 
LVL 34

Expert Comment

by:Beverley Portlock
ID: 34887017
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this. Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it i…
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

617 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question