Is there a function for switching/inverting boolean value in PHP?
boolean
Like... a shortcut for:
if($boolean === true){ $boolean = false; }else{ $boolean = true; }
Yes:
$boolean = !$boolean;
if it's not a boolean value, you can use the ternary construction:
$int = ($some_condition ? 1 : 2); // if $some_condition is true, set 1 // otherwise set 2
1.4m articles
1.4m replys
5 comments
57.0k users