PHP 8.4.0 Alpha 1 available for testing

Voting

: max(eight, six)?
(Example: nine)

The Note You're Voting On

Greg Hartwig
16 years ago
David from CodeXplorer:
>> The ONLY reason to use empty() is for code readability. It is the same as an IF/ELSE check.
>> So, don't bother using EMPTY in the real world.

This is NOT true. empty() will not generate warnings if you're testing against an undefined variable as a simple boolean check will. On production systems, warnings are usually shut off, but they are often active on development systems.

You could test a flag with
<?php if ($flagvar) ... ?>
but this can generate a warning if $flagvar is not set.

Instead of
<?php if (isset($flagvar) && $flagvar) ... ?>
you can simply use
<?php if (!empty($flagvar)) ... ?>

for easy readability without warnings.

<< Back to user notes page

To Top -