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 ...
Get PHP Quick Scripting Reference now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.