Solved

PHP If statements. Stacked parentheses explained?

Posted on 2012-04-04
2
155 Views
Last Modified: 2012-04-04
Hi,

Can someone please explain the proper use of stacked parentheses like so:

if( $x == 3 && $y == 8 ){
    echo 'hi';
}

Against:

if( ( $x == 3 ) && ( $y == 8 ) ){
    echo 'hi';
}

What would be the significance of the added parentheses?

Thank you
0
Comment
Question by:wilson1000
2 Comments
 
LVL 108

Accepted Solution

by:
Ray Paseur earned 500 total points
Comment Utility
Just like math class -- to distinguish which comparisons are executed first.
0
 
LVL 4

Author Closing Comment

by:wilson1000
Comment Utility
Thank you
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

I've been asked to discuss some of the UX activities that I'm using with my team. Here I will share some details about how we approach UX projects.
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
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.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

762 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

5 Experts available now in Live!

Get 1:1 Help Now