Solved

PHP If statements. Stacked parentheses explained?

Posted on 2012-04-04
2
157 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 109

Accepted Solution

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

Author Closing Comment

by:wilson1000
ID: 37806466
Thank you
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Where can I find... 1 34
business account would work but I have a regular paypal account 2 87
javascript: add id amounts 5 47
PHP AJAX Wordpress 9 21
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.
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
Viewers will get an overview of the benefits and risks of using Bitcoin to accept payments. What Bitcoin is: Legality: Risks: Benefits: Which businesses are best suited?: Other things you should know: How to get started:
The viewer will learn how to dynamically set the form action using jQuery.

803 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