Hi,
I was just wondering what is the difference between these 2 queries (if any)
[syntax=php]
if(isset($_GET['a']) && (strlen($_GET['a'])) == 32 && (ctype_alnum($_GET['a']))) {
//****** AND ********//
if(isset($_GET['a']) && strlen($_GET['a']) == 32 && ctype_alnum($_GET['a'])) {
[/syntax]
I normally use the bottom kind but was just playing with some code and noticed it was still valid with the brackets around each condition too. Do they differ at all in execution?
difference in these queries
Re: difference in these queries
In this case there's no difference since every condition has to evaluate to TRUE. If you want to make more complex check you need to extra ( and ) to separate different parts of a statement. You can also use it to make it more readable for yourself:
[syntax=php]if ((2 == 2 || 3 == 3) && (4 == 4 || 5 == 5)) {[/syntax]
[syntax=php]if ((2 == 2 || 3 == 3) && (4 == 4 || 5 == 5)) {[/syntax]
Re: difference in these queries
Thanks Libeco