Is there a need to initalize properties inside a class to null if php automatically does it for you?
<p>Doing a var_dump on an object from either of the two classes gives the same result</p>

<pre><code>Class Node{
    public $parent = null;
    public $right = null;
    public $left = null;        
    function __construct($data){
        $this-&gt;data = $data;                    
    }
}

Class Node{
    public $parent;
    public $right;
    public $left;        
    function __construct($data){
        $this-&gt;data = $data;                    
    }
}
</code></pre>

<p>For example</p>

<pre><code>$a = new Node(2);
var_dump($a);
</code></pre>

<p>returns the following for either of the above classes</p>

<pre><code>object(Node)#1 (4) {
  ["parent"]=&gt;
  NULL
  ["right"]=&gt;
  NULL
  ["left"]=&gt;
  NULL
  ["data"]=&gt;
  int(2)
}
</code></pre>

<p>This doesn't seem to be the case for variables.</p>

<pre><code>$b;
var_dump($b);
</code></pre>

<p>If you intend for the property to have a value of <code>null</code> is there a need to explicitly write that since php seems to do it automatically for you?</p>

<p>Also - According to this answer <a href="http://stackoverflow.com/a/6033090/784637">http://stackoverflow.com/a/6033090/784637</a>, C++ gives undefined behavior if you try to get the value of an unintialized variable.  Does C++ automatically set the value of a property in a class to <code>null</code> the way php does, if that property is uninitialized to a value?</p>
