title: php how do I set different types of throw errors
body: <p>In JavaScript this is how I create throw errors if the parameter of a function is a invalid type.</p>
  <pre><code>function myFunction(num)
      if (typeof(num) !== 'number') {
          throw TypeError('num cannot be' + num);
      }
  }
  </code></pre>
  <p>How do I do this on PHP? I know there is a throw command but how do you set the error type. In the JavaScript example above I set it to be a TypeError, how do you set the error type for a PHP throw error and what are the error types in PHP?</p>
  <pre><code>function myFunction($num)
      if (gettype($num) !== 'boolean') {
          throw new Exception('$num cannot be ' , $num);;
      }
  }
  </code></pre>