Reputation: 1644
So in the base PHP Functions (probably not a good reference but anyway) example, the function array_push($arr, $info)
- you can put as many items in the $info
variable as you want, but example if you don't put in a paramater in a function that you made, example public function __connstruct($conn_string, $drivers)
, how would one want to achieve making the $drivers
variable not needed unless the function is called with it.
Is it a special type of variable in the function?
Upvotes: 0
Views: 29
Reputation: 198
Try this: default arguments
public function __construct($conn_string, $drivers = null)
{
// do something
}
This makes $drivers an optional function argument
Upvotes: 2