title: PHP Optional Function Arguments
body: <p>I'm a little stuck trying to create a function that takes a single, optional argument. Instead of this being a string I'd like it to be the result of a function (or even better, a DateTime object). Essentially - I want the user to either pass in a DateTime object, or for the function to resort to todays date if no arguments are supplied. Is this possible with PHP? By trying to create the new object in the function header as such</p>
  
  <pre><code>function myDateFunction($date = new DateTime()){
  //My function goes here.
  }
  </code></pre>
  
  <p>causes PHP to fall over.</p>
  
  <p>Many thanks.</p>