title: Fatal error: Call to a member function display() on a non-object
body: <p>this is my code for creating a list of data elements ! 
   in this below line mentioned there are two error(on the same line) </p>
  
  <p>1)Notice: Undefined offset: 0
  2)Fatal error: Call to a member function display() on a non-object   </p>
  
  <pre><code>  &lt;?php
    class data
    {
       public $num;
       public $Char;
  
  
      function __construct()
      {
        $this-&gt;num= "null";
        $this-&gt;Char= "New Char";    
      }
  
      public function setInt($int)
      {
        $this-&gt;num=$int;
      }
  
      public function setChar($char)
      {
        $this-&gt;Char= $char;
      }
  
  
      public function getInt()
      {
        return $this-&gt;num;
      }
  
      public function getChar()
      {
       return $this-&gt;Char;
      }
  
      public function display()
      {
        echo $this-&gt;num;
        echo $this-&gt;Char;
      }
    }
  
    class linklist extends data 
    {
      public $DATA;
      private $list;
      private $count;
  
      function __construct()
      {
        $DATA= new data();
        $list= array();
        $count=0;
      }
  
      function addData(data $d)
      {
         $this-&gt;list[$this-&gt;count]= $d;
  
       $this-&gt; count++;
      }   
  
      function displayy()
      {
          $d= new data();
          $i=0;
        for($i;$i&lt;=$this-&gt;count; $i++)
        {
          $this-&gt;list[$i]-&gt;display();   //** line with error *** //
        }
  
      }
    }
  
  
  
  
  ?&gt;
  
  
  
  
  &lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;body&gt;
  &lt;?php
     $d= new data();
  
       //$d-&gt;display();
  
       //$Name= $_POST['fname'];
       //$Age = $_POST['age']; 
  
  
       $d-&gt;setInt("1");    
       $d-&gt;setChar("Ashad");   
  
       //$d-&gt;display();
  
       $d1= new Data();
  
       $d1-&gt;setInt("2");   
       $d1-&gt;setChar("shahrukh");   
  
       $list = new linklist();
  
       $list-&gt; addData($d);
       $list-&gt;addData($d1);
  
  
      $list-&gt;displayy();
  
  
  ?&gt;  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>