O'Reilly logo

PHP Quick Scripting Reference by Mikael Olsson

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

CHAPTER 20

image

Variable Testing

PHP has a number of built-in constructs that can be used to test the value of a variable. All these functions return a bool value.

Isset

The isset language construct returns true if the variable has been assigned a value other than null.

isset($a); // false $a = 10;isset($a); // true $a = null;isset($a); // false

Empty

The empty construct checks whether the specified variable has an empty value – such as null, 0, false or an empty string – and returns true if that is the case. It also returns true if the variable does not exist.

empty($b); // true $b = false;empty($b); // true

Is_null

The is_null construct can ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required