|
call_user_method
Call a user method on an specific object [deprecated]
(PHP 4, PHP 5)
Warning:
The call_user_method() function is deprecated
as of PHP 4.1.0, use the call_user_func() variety
with the
See Also
Code Examples / Notes » call_user_methodjmcastagnetto
You can pass a variable number of parameters to a function, use a definition like: function mymethod ($v1, $v2, $v3="", $v4="") and then you can pass 2, 3 or 4 parameters. This is explained in the "Functions" section of the manual. See also the PHP4 functions: func_num_args(), func_get_arg(), and func_get_args(), and examples therein jonathanmaps_on
You can also dynamically call functions through variable variables...for example: <?php class xyz{ function mybar($str) { echo $str; } } $xyz = new xyz; $foo = 'bar'; $xyz->{'my'.$foo}('dynamic call to function'); ?> paulo
This function is very similar to this: $method="Print"; $object->$method($param1,$param2); Note the extra $ after the -> j dot h
It does not work to use Pointers as Arguments: <?php class abc{ function func(&$argument) { $argument="It works"; } } $obj=new abc; $argument_to_be_changed="No it doesnt"; call_user_method("func", $obj, $argument_to_be_changed); echo "Result".$argument_to_be_changed; ?> The result is: "No it doesnt". Regards der Jan |