Is possible to set a DateTime
object as optional parameter using now
as default?
下面的法典给我一个syntax差错:
public function getData(array $metrics, DateTime $start,
DateTime $end = new DateTime, $params = array())
{
// Default DateTime constructor automatically use "now"
}
它只是一个好奇的问题,i 知道一能够做到:
public function getData(array $metrics, DateTime $start,
DateTime $end = null, $params = array())
{
$end = is_null($end) ? new DateTime() : null;
}