What does this mean in documentation: square bracket followed by comma ( [, ) [duplicate]
Today this caught my attention on jQuery's API Documentation for the closest
selector:
.closest( selector [, context ] )
What exactly does [, context]
mean? I know I can put a variable or jQuery object there to set as the context. This itself isn't entirely clear to me, but the part in particular I'm asking about today is the square bracket comma ( [,
). What does this mean? I've also seen similar notation on php.net's manual pages.
bool ob_start ([ callable $output_callback [, int $chunk_size = 0 [, ...
Is there some preliminary lesson I've missed? because this is greek to me and I can't be the only one who's looked at this and thought "WTF..." but ignored it and went on guessing, when I could have saved a lot of time...
Solution 1:
It means that parameter is optional. You don't have to provide it and if you don't it will use the value you see listed there by default.
Solution 2:
Funnily enough, there's a dedicated page in the PHP manual on how to read a function definition. So, quoting the mentioned page:
All optional parameters are seen in [ brackets ].
Also, manual's "About the manual" is an interesting read, if you are into that.