First post: Optional parameters in PHP function prototypes Why do you write this?
First, let's start. Write something simple.
Just started to learn PHP, when looking at PHP manual encountered a problem: in the function prototype with optional parameters, the optional parameters of the wording can not understand.
such as the Explode function
Array explode (string $delimiter, string $string [, int $limit])
Optional parameters are enclosed in "[square brackets]", then the third parameter is $limit optional.
But why not write it like this:
Array explode (string $delimiter, string $string, [int $limit])
It is impossible to understand the position of this comma.
-
1/ F deanchopper
-
Optional refers to something inside [] that is optional instead of a parameter, so press your way regardless of whether there is a final parameter after the second argument there is one, obviously this is not possible
-
Re: yangtoude
-
@DeanChopper, understand, thank you!