Using function result as a default argument in PHP function
<p>I'm writing a function which requires some units of date, like "hour", "minute" and "second" but I would like to make these option and the server's current time is used as the default.</p>

<p>In PHP's <code>mktime(..)</code> I notice that they use function calls to get the default argument value - but when I try this, it doesn't work:</p>

<p>PHP's appears to be like this:
<code>mktime([int $hour = date("H")[,int $minute= date("i")[,etc...</code></p>

<p>And I've tried to copy this into my function, exactly the same (just not as many arguments until I get it working): <code>function myFunc([int $hour = date("H")[,int $minute= date("i")]]) {</code></p>

<p>Using this code, PHP tells me <code>Parse error: syntax error, unexpected '[', expecting '&amp;' or T_VARIABLE in ...</code> </p>

<p>I've tried searching for this - but managed to find nothing on the topic. My question is, is this possible for me to do or am I going to have to specify null as the parameters and then check them inside the function like so:</p>

<pre><code>function myFunc($hour=null,etc...) {
  if($hour==null){$hour=date("H");}
  //etc...
}
</code></pre>

<p>As for justification of why I want to know this other than using the solution I've provided to myself - I'm still learning PHP and want to learn the best practises.</p>
