As we all know if a variable is created without a value, it is automatically assigned a value of NULL.
I have following code snippets :
<?php
$name;
echo $name;
?>
AND
<?php
$name;
print $name;
?>
Both of the above code snippets' output is as below(it's exactly the same) :
Notice: Undefined variable: name in C:\xampp\htdocs\php_playground\demo.php on line 7
I have another code snippet :
<?php
$name;
var_dump($name);
?>
The output of above(last) code snippet is as below :
Notice: Undefined variable: name in C:\xampp\htdocs\php_playground\demo.php on line 8
NULL
So, my question is why the value "NULL" is not getting displayed when I tried to show it using echo and print?
However, the "NULL" value gets displayed when I tried to show it using var_dump() function.
Why this is happening?
What's behind this behavior?
Thank You.