up

How to use function value as default argument value?

function foo($year = date('Y')) {
  // this is invalid
}

So, how should do it?

define('THIS_YEAR', date('Y'));
function bar($year = THIS_YEAR) {
  // this is valid
}

Add new comment