开发者

PHP: skipping a default parameter in a function call

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜