note 103883 rejected from control-structures.if by thiago
| From: | thiago@php.net | Date: | Mon, 09 May 2011 04:01:43 +0000 |
| Subject: | note 103883 rejected from control-structures.if by thiago | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-179553@lists.php.net to get a copy of this message | ||
Note Submitter: Chozo at juno dot com
----
Noticed an issue when noticing an IF statement wasn't working as it was expected to.
I am unsure if it's due to the php version [5.2.17] at this time or the move from a Windows
server to a *nix server but IF statements are not being handled as expected anymore. Whereas a
variable would be re-used and then set to a variable [different, same, or otherwise] during the IF.
Take this tidbit:
<?php
//Previously this worked as expected [md5 function being used as an example].
var $pass=md5('test1');
if($pass!==($pass=md5('test2'))) echo 'True';
else echo 'False';
//End
?>
Expected result: 'True'
Result now with 5.2.17: 'False'
Previously this would be TRUE due to $Pass being changed to the other md5 for comparison to self
since the variable is intended for reuse within the IF block under the new MD5 (taking advantage of
the Left to Right antics of conditionals with paranthetic entries being calculated/run before
comparison).
However, now for some reason - it is being considered FALSE because the second MD5 is NOT being set
until after the whole if statement comparison has completed [as if parenthesis are being ignored],
resulting in the block to never execute. It isn't only functions being used as it's any
variable being set within the IF - function or not.