So you can see there are limitations (at least in this version).
Quote:
my suggestion is to provide the method signature with a $flag = null variable, which you call a SWITCH on to pick what the data should do
which i do not understand
|
Ok, this is very simple. Here's an example (
UNTESTED):
PHP Code:
class SomeClass
{
function some_method( $flag= null ) {
if ( is_null($flag) ) {
return 'default value';
} else {
switch($flag) {
case 'foo':
return 'foo passed';
case 'bar':
return 'bar passed';
default:
return "args: 'foo' | 'bar'";
}
}
}
}
The method's signature has an argument with a default value, null. If you decide to call it with no arg, e.g.
$obj->some_method(), then the default action is taken. If you pass an arg, e.g.
$obj->some_method('foo'), then the switch statement triggers the appropriate action.
I'm sure there are examples using
func_get_args() as well.