Undefined variables are those that have not yet been initialized with a value prior to being read.
⚠️ If we use an undefined variable we receive a warning and the PHP script continues its execution. Example:
<?php
$audience = "World";
echo $message;
echo $audience;
?>
After have ran the previous code, we’re going to receive this warning message:
PHP Warning: Undefined variable $message in index.php on line 4
However PHP still will print the value of the variable $audience:
World
This behavior is going to change on PHP 9, where it will throw an error, according to this RFC PHP: rfc:undefined_variable_error_promotion.