logical AND assignments

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



My ISP upgraded his server from Ubuntu 9.04 to Ubuntu 9.10, which
probably included a newer PHP version.  I don't know what PHP version
was on previously.  Code I've had running for years broke, and I tracked
it down to this equivalent:

<?php

echo 'Current PHP version: ', phpversion(), "<br><br>";

$Condition0 = true and false;
If ($Condition0)
	echo "Condition0<br>";
	else echo "Not Condition0<br>";

$Condition1 = false and true;
If ($Condition1)
	echo "Condition1<br>";
	else echo "Not Condition1<br>";

$Condition2 = (true and false);
If ($Condition2)
	echo "Condition2<br>";
	else echo "Not Condition2<br>";

$Condition3 = true && false;
If ($Condition3)
	echo "Condition3<br>";
	else echo "Not Condition3<br>";

$Condition4 = (true && false);
If ($Condition4)
	echo "Condition4<br>";
	else echo "Not Condition4<br>";
?>

which returns:

Current PHP version: 5.2.10-2ubuntu6.4

Condition0
Not Condition1
Not Condition2
Not Condition3
Not Condition4

===============================

I added parentheses around the offending line of code and it seems okay
now.  But I am stymied as to why they're required at all.  They never
were before, and as far as I see there is no PHP requirement to include
the parentheses.  Have I done something silly?  Mostly I'm worried if
there are any other changes I need to make.  I searched my code and
hopefully found all similar instances, but who really knows about those
kinds of things?

Any comments?

---Robert


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux