title: php parent constructor in Exception Class
body: <p>So I was reading the PHP manual again and saw a comment on the code of a custom exception to call the parent Exception constructor and do not understand the purpose of this.</p>
  
  <p>Here is the code:</p>
  
  <pre><code>class MyException extends Exception
  {
          // Redefine the exception so message isn't optional
          public function __construct($message, $code = 0) {
          // some code
  
          // make sure everything is assigned properly
          parent::__construct($message, $code);
      }
  
      // custom string representation of object
      public function __toString() {
      return __CLASS__ . ": [{$this-&gt;code}]: {$this-&gt;message}\n";
      }
  
      public function customFunction() {
          echo "A custom function for this type of exception\n";
      }
  }
  </code></pre>
  
  <p>I don't understand the logic of:</p>
  
  <pre><code>//make sure everything is assigned properly
  parent::__construct($message, $code);
  </code></pre>
  
  <p>Any logic as to why this is done would be helpful.</p>