title: abstract class in php
body: <p>I have some code below</p>
  
  <pre><code>/*abstract*/ class Animal{
      protected $name;
      protected $legs;
  
      public function setName($name){
          $this-&gt;name = $name; 
      }
  
      public function getName(){
          return $this-&gt;name;
      }
  
      // abstract public function sound();
  }
  
  
  class Cat extends Animal{
      public function sound(){
          echo 'Meo meo meo';
      }
  }
  
  class Crocodile extends Animal{
      public function sound(){
          echo 'Never hear it';
      }
  } 
  
  function check(Animal $a){
      echo $a-&gt;getName();br();
      echo $a-&gt;sound();br();
  }
  
  $cat = new Cat();
  $cat-&gt;setName("Cat");
  
  $cro = new Crocodile();
  $cro-&gt;setName('Nothing');
  
  
  class test{
      public function check(Animal $a){
          echo $a-&gt;getName();
          echo $a-&gt;sound();
      }
  }   
  
  
  $t = new test();    
  $t-&gt;check($cro);    
  </code></pre>
  
  <p>I think, if don't use abstract so the last line $t->check($cro) must wrong, but Why it run nice.
  I want ask a question, in class test with check method, $a->sound(); no exists in Animal but it still run. It run like when I open comment abstract class, both of thing is not different. I really wonder, maybe I have wrong understood this problem, twisted </p>