Negating An Assignation¶
<?php
// $e contains the check
!$e = checkSomething();
// $e contains the check,
// and the condition still passes
if (!$e = checkSomething()) {
print "Something was wrong!";
}
I always wondered why PHP allows to NOT a variable on the LEFT side of an assignation.
It makes sense with an iffectation (an assignation within an if)
I’m sure other such expressions are possible, with unary operators.
Definitely not for me, for readability reasons; same as !$o instanceof X.
See Also¶
PHP Features¶
Last updated: 14 July 2026