PHP Empty

Reference on the Empty Function of PHP. Including useful examples, and a list of things that are considered to be Empty.

The Empty function of php, checks whether a variable is Empty or not.

The following is considered to be Empty.

"" An empty String
0 Zero declared as an Integer
0 Zero declared as a String
NULL The constant NULL
FALSE The keyword FALSE
var $MyVar; Declared variables with no value.

Example

Below is using a PHP If statement, to check if a variable was Empty.

if (empty($var)) {
    echo '$MyVar is considered Empty';
}

Post comment

Links that you insert are not nofollowed, but will be removed by admins if they are considered spam.

[url=Absolute URL for page]TITLE[/url]

You should insert code boxes around code examples, which will be automatically syntax highlighted.

[code1 html|css|javascript|php|sql]Your Code Here[/code1]

You may want to read our Privacy Policy before submitting your comment.