I just started learning PHP and I have some questions about the parameters. Consider DateTime class
PHP DateTime Class Manual
public __construct ([ string $time = "now" [, DateTimeZone $timezone = NULL ]] )
public DateTime setDate ( int $year , int $month , int $day )
Here's my question:
setDate
parameters aren't in brackets?[,
?Thanks in advance.
The parameters in brackets are optional. Therefore, if I initialize the DateTime class and don't provide the second parameter, it takes the default value of null
.
Nested brackets just means this: If I were to initialize the DateTime class, I provid either parameter 1 or parameter 1 and 2, or none at all. I cannot opt to provide no parameter 1, but a value for parameter 2.
The comma just seperates the different parameters in the function's signature if more than 1 is provided..