How to read function definition in PHP manual

后端 未结 1 912
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-13 21:12

I was going through the PHP documentation for this function below and trying to understand what [, before the 2nd parameter means?

string basename ( string         


        
1条回答
  •  广开言路
    2021-01-13 22:08

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

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

    This is a function basename which takes a $path argument and, optionally a $suffix argument. It returns a string.

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

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

    In this case the $length argument is optional and the value 0 will be used if it is not supplied.

    0 讨论(0)
提交回复
热议问题