开发者

PHP: skipping a default parameter in a function call

开发者 https://www.devze.com 2023-01-31 06:54 出处:网络
The below is a php function: bool mkdir ( string $pathname [, int $mode = 0777 [, bool $recursive = false [, resource $开发者_如何学Gocontext ]]] )

The below is a php function:

bool mkdir ( string $pathname [, int $mode = 0777 [, bool $recursive = false [, resource $开发者_如何学Gocontext ]]] )

I would like to call the function, specifying the first and the third parameters, leaving the second default. Can I?


No, you cannot. See http://www.php.net/manual/en/functions.arguments.php esp. ex #5 and #6

Specifically:

Note that when using default arguments, any defaults should be on the right side of any non-default arguments; otherwise, things will not work as expected.


Make a wrapper function with only the parameters you want to specify.

0

精彩评论

暂无评论...
验证码 换一张
取 消