PHP 8.5.0 Alpha 1 available for testing

Voting

: max(one, one)?
(Example: nine)

The Note You're Voting On

Hayley Watson
12 years ago
You don't need to check that a variable is set before you unset it.
<?php
unset($a);
?>
is harmless.
<?php
if(isset($a)) {
unset(
$a);
}
?>
is pointless complication.

This doesn't apply to properties of objects that have __isset() methods that visibly change object state or __unset() methods that don't properly check their arguments or have extra side effects.

The latter case means that __unset shouldn't do more than what it says on the tin, and also has the responsibility for checking (possibly using __isset()) that what it's being asked to do makes sense.

The former case is just plain bad design.

<< Back to user notes page

To Top