0

I understand that question like that one could sound a little bit absurdly, but it disturbs me already for a pretty long time and I haven't succeeded to find an answer myself.

The issue is in PHP's official function reference. Can somebody explain me what does " [, int $blablabla ]" means in function's prototype?

For example, here how it comes in php.net:

array str_split ( string $string [, int $split_length = 1 ] )

Why does the comma sign comes after the bracket? What does it supposed to mean? And why the hell there is no comma after "string $string" parameter?

I really appreciate if someone could help me to resolve that kind of a mosaic... Tnx.

Splanger
  • 169
  • 1
  • 8

2 Answers2

4

It's an optional parameter. Any parameter listed between brackets are optional.

erKURITA
  • 397
  • 2
  • 13
  • 2
    and since the parameter is optional, the comma is optional unless you include the optional parameter. – Kevin B Oct 04 '13 at 14:34
2

It means that the particular argument is optional, and the value after the = is the default value.

In this case, $split_length is optional, and if you call str_split with only 1 argument, $split_length will automatically pass as 1.

bizzehdee
  • 20,289
  • 11
  • 46
  • 76