phpreference-manual

Syntax of Functions in PHP manual


I have hard time understanding the syntax of the following function (and others alike):

int fwrite ( resource $handle , string $string [, int $length ] )

what is the meaning of the brackets and comma that follows [, int $length ]. what it should indicate?


Solution

  • The the following example:

    int fwrite ( resource $handle , string $string [, int $length ] )
    
    1. The first int represents the data type returned by the function
    2. The expected datatype of each parameter precedes the parameter name
    3. The square brackets indicate optional parameters i.e. the parameters that you can omit
    4. An optional parameter might be followed by a = <some value> indicating the default value that is used if you omit that parameter