How to read function definition in PHP manual

I looked at the PHP documentation for this function below and tried to figure out what [before the second parameter is specified?

string basename ( string $path [, string $suffix ] )

Why not just mention it below:

string basename ( string $path , string $suffix )

The above explanation should help me understand the following function definition:

array fgetcsv ( resource $handle [, int $length = 0 [, string $delimiter = "," [, string $enclosure = '"' [, string $escape = "\" ]]]] )
+4
source share
1 answer

[]just indicates that the argument is optional. In your example:

string basename ( string $path [, string $suffix ] )

This is a function basenamethat takes an argument $pathand, optionally, an argument $suffix. He returns string.

There may also be an initial value, as in your second example:

array fgetcsv ( resource $handle [, int $length = 0 [, string $delimiter = "," [, string $enclosure = '"' [, string $escape = "\" ]]]] )

In this case, the argument $lengthis optional, and the value 0will be used if it is not specified.

+5
source

Source: https://habr.com/ru/post/1589464/


All Articles