php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #1460 empty() != !isset()
Submitted: 1999-05-27 10:31 UTC Modified: 1999-05-27 10:38 UTC
From: aulbach at unter dot franken dot de Assigned:
Status: Closed Package: Misbehaving function
PHP Version: 3.0.8 OS: Linux 2.0
Private report: No CVE-ID: None
 [1999-05-27 10:31 UTC] aulbach at unter dot franken dot de
Perhaps it is a documentation error:

<?

$val='';

        if (empty($val) || ''==$val)
                echo "empty(): EMPTY<BR>";
        else
                echo "empty(): NOT EMPTY<BR>";

        if (!isset($val))
                echo "isset(): EMPTY<BR>";
        else
                echo "isset(): NOT EMPTY<BR>";
?>

Results:
empty(): EMPTY
isset(): NOT EMPTY

If I read the docs, then empty() should be !isset(), so the result must be the same

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [1999-05-27 10:36 UTC] aulbach at unter dot franken dot de
oops, of course the

     if (empty($val) || ''==$val)

is a little bit corrupted, should be replaced by

     if (empty($val))

But the result is the same.

 [1999-05-27 10:36 UTC] andrey at cvs dot php dot net
isset() returns true if the variable is set, which it is in this case, so !isset() 
will result in "NOT EMPTY" in your case.  Basically, empty() and !isset() are not
equivalent.

 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Thu Oct 08 11:00:02 2026 UTC