Created
April 2, 2014 15:58
-
-
Save ilya-dev/9937057 to your computer and use it in GitHub Desktop.
To prevent an accidental assignment when comparing two variables, wrap the first one within parentheses.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$foo = 10; $bar = 9; | |
var_dump($foo = $bar); // whoops, accidental assignment! but no message will be displayed | |
var_dump(($foo) = $bar); // again, but this is a syntax error b/c an expression can't have a value assigned to it! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment