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?

You may also like...

Leave a Reply