⊗ppPmCdWSu 88 of 447 menu

Suppressing Warnings in PHP

Let the variable $test be undefined. As you already know, the value of such a variable will be equal to null. However, an attempt to access this variable will result in a warning:

<?php var_dump($test); // will output null and a warning ?>

A warning will also be shown when trying to check the variable against null:

<?php if ($test !== null) { echo '+++'; } else { echo '---'; } ?>

However, a check using the isset command will not result in a warning - it will be automatically suppressed:

<?php if (isset($test)) { echo $test; } else { echo 'variable does not exist'; } ?>
byenru