August 2013
Intermediate to advanced
140 pages
1h 49m
English
CHAPTER 20
![]()
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 ...
Read now
Unlock full access