Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

if statement if (!empty

Posted on 2011-02-14
3
Medium Priority
?
358 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 2000 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
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…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

664 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