Variables declared without a value and undefined / undeclared variables are null by default.
However, just doing $var; will not declare a variable, so you can declare a variable without a value in the object.
Demo:
<?php class Test { public $var; } $var; $t = new Test(); var_dump($var); var_dump($t->var);
Output:
Notice: Undefined variable: var in - on line 5 NULL NULL
Thiefmaster
source share