Solved

if statement if (!empty

Posted on 2011-02-14
3
342 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
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How can I run the php script or the page without visiting the page? 6 52
Animated .jpg? 13 60
get domain with php 7 20
How to convert my query to the proper format? 5 17
Both Easy and Powerful How easy is PHP? http://lmgtfy.com?q=how+easy+is+php (http://lmgtfy.com?q=how+easy+is+php)  Very easy.  It has been described as "a programming language even my grandmother can use." How powerful is PHP?  http://en.wikiped…
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn how to count occurrences of each item in an array.
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…

920 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now