LiranC
LiranC

Reputation: 2480

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?

Upvotes: 0

Views: 50

Answers (3)

Salman Arshad
Salman Arshad

Reputation: 272106

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

Upvotes: 0

briosheje
briosheje

Reputation: 7446

[, int $length] indicates an optional parameter you may add when you use the comfort function fwrite. Moreover, it also tells you that it has to be an integer.

Upvotes: 0

opalenzuela
opalenzuela

Reputation: 3171

It's simply an optional parameter.

Upvotes: 2

Related Questions