Skip to Main Content
PHP in a Nutshell
book

PHP in a Nutshell

by Paul Hudson
October 2005
Intermediate to advanced content levelIntermediate to advanced
372 pages
11h 35m
English
O'Reilly Media, Inc.
Content preview from PHP in a Nutshell

Name

empty()

Synopsis

    bool empty ( mixed var )

The empty() function returns true if its parameter has a false value. This is not the same as the isset(): if a variable was set and had a false value (such as 0 or an empty string), empty() would return false, and isset() would return true.

    $var1 = "0";
    $var2 = "1";
    $var3 = "";

    if (empty($var1)) print "Var1 empty\n";
    if (empty($var2)) print "Var2 empty\n";
    if (empty($var3)) print "Var3 empty\n";
    if (empty($var4)) print "Var4 empty\n";

That would print "Var1 empty", "Var3 empty", then "Var4 empty".

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

PHP Cookbook

PHP Cookbook

Eric A. Mann
Programming PHP

Programming PHP

Rasmus Lerdorf, Kevin Tatroe
Learning PHP

Learning PHP

David Sklar

Publisher Resources

ISBN: 0596100671Errata Page