Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - [php] How to set a parameter of a function as dispensable?
[php] How to set a parameter of a function as dispensable?
Set the default value for the parameter, but only the last parameter can be omitted. If parameters with default values are placed in the middle, you must leave a comma in the middle to separate them. Here are some examples:

Function getdata($a, $b, $c=0){

....

}

The above paragraph can only give two parameters when calling, and the default value of the third parameter is 0.

Call method: getdata( 1, 1)

==========================================================

Function getdata($a, $b= 1, $c){

....

}

This paragraph should be called in the middle with a comma, for example: get data (1, 0).

==========================================================

Function getdata($a, $b=0, $c= 1){

....

}

This part can be called as follows: getdata( 1)