O'Reilly logo

PHP 7 Quick Scripting Reference, Second Edition 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

© Mikael Olsson 2016

Mikael Olsson, PHP 7 Quick Scripting Reference, 10.1007/978-1-4842-1922-5_20

20. Variable Testing

Mikael Olsson

(1)Hammarland, Finland

As a web-focused language, it is common in PHP to process user-supplied data. Such data needs to be tested before it is used to confirm that it exists and has a valid value. PHP provides a number of built-in constructs that can be used for this purpose.

Isset

The isset language construct returns true if the variable exists and 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 ...

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