title: PHP Overriding methods rules
body: <p>I just read from the book: <br>
  &quot;In PHP 5, except for constructors, any derived class must use the same signature when overriding a method&quot;<br>
  From the PHP manual in the comments: <br>
  &quot;In the overriding, the method names and arguments (arg’s) must be same.<br>
  Example:<br>
  class P { public function getName(){} }<br>
  class C extends P{ public function getName(){} }
  &quot;</p>
  <p>
  So why I'm able to replace method with other arguments and their quantity? Is this legal or will trigger errors in the future or I'm just missing something?
  </p>
  <p>PHP Version 5.5.11</p>
  <pre><code>class Pet {
      protected $_name;
      protected $_status = 'None';
      protected $_petLocation = 'who knows';
  
  // Want to replace this function
      protected function playing($game = 'ball') {
          $this-&gt;_status = $this-&gt;_type . ' is playing ' . $game;
          return '&lt;br&gt;' . $this-&gt;_name . ' started to play a ' . $game;
      }
  
      public function getPetStatus() {
          return '&lt;br&gt;Status: ' . $this-&gt;_status;
      }
  }
  
  
  class Cat extends Pet {
  
      function __construct() {
          $this-&gt;_type = 'Cat';
          echo 'Test: The ' . $this-&gt;_type . ' was born ';
      }
  
  // Replacing with this one    
      public function playing($gameType = 'chess', $location = 'backyard') {
          $this-&gt;_status = 'playing ' . $gameType . ' in the ' . $location;
          return '&lt;br&gt;' . $this-&gt;_type . ' started to play a ' . $gameType . ' in the ' . $location;
      }
  }
  
  $cat = new Cat('Billy');
  echo $cat-&gt;getPetStatus();
  echo $cat-&gt;playing();
  echo $cat-&gt;getPetStatus();
  </code></pre>
  <p>
  This will output:
  </p>
  <p>Test: The Cat was born <br>
  Status: None<br>
  Cat started to play a chess in the backyard<br>
  Status: playing chess in the backyard<br></p>