Can you pass more parameters than a function expects? Can you pass more parameters than a function expects? php php

Can you pass more parameters than a function expects?


There are two ways to do this:

Extend the methods to use default parameters:

public function doSomething($input=null) {}

Note that you'll need to do this for all instances, even if it isn't used.

In this case, you may want to use the arguments array of the method:

public function doSomething() {  $args = func_get_args();  if (isset($args[0])) { $this->doSomethingElse();}