Boolean toggle in PHP

Instead of using:

if($boolean === true){
    $boolean = false;
}else{
    $boolean = true;
}

One can use

$boolean = !$boolean;

So short and sweet right?

Leave a Reply

Close Menu
%d bloggers like this: