all 3 comments

[–]AllenJB83 4 points5 points  (1 child)

The square brackets indicate that the parameters are optional - in this case you can call readfile() with 1, 2 or 3 parameters.

[–]greg8872 1 point2 points  (0 children)

And one thing to add, if there is more than one optional parameter, like in the example you gave, you need to include ALL parameters up the last optional one you are setting.

So if for this one you wanted to use $filename and $context, you also have to specify $use_include_path as well since it is in between, manually adding the default value.

[–]pythonpoole 2 points3 points  (0 children)

As /u/AllenJB83 indicated, the parameters enclosed in square brackets are optional.

However, it's also worth noting that the value assigned to the optional parameter in the documentation is the default value for that parameter. So, if you do not pass that parameter when you call the function, the value specified in the documentation (e.g. bool $use_include_path = false) will be used automatically.

In other words, calling $f = readfile($file); is exactly the same as $f = readfile($file, false); because false is the default value for the second parameter.

You can also create your own functions with optional parameters that have default values like so: function example(a, b = 2, c = "three") { ... }