Skip to content

Instantly share code, notes, and snippets.



Created Apr 2, 2014
What would you like to do?
To prevent an accidental assignment when comparing two variables, wrap the first one within parentheses.
$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