Using function result as a default argument in PHP function

前端 未结 1 1120
南方客
南方客 2021-01-13 04:23

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 u

相关标签:
1条回答
  • 2021-01-13 04:32

    A default function argument should be a compile time constant. Or in PHP's case the value should be known to the PHP interpreter before executing the script.

    Therefore you cannot directly use function result as a default argument

    Thus only way is the null default argument method you already know.

    0 讨论(0)
提交回复
热议问题