-1

How to call a function with multiple default value in PHP ?

I have a function like below

public function get( $action = 'find', $query = 'top' ) {
      //more code
}

What will happen if I call above function like below (with one value) ?

get('map') {
      //more code
}
abu abu
  • 6,599
  • 19
  • 74
  • 131

1 Answers1

0

You are using positional arguments. Passing only one argument in your function, becomes the value of first parameter i.e. $action The $query still has the value of 'top'.