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
call_user_method
(PHP 4, PHP 5)
call_user_method — Ruft eine benannte Methode eines Objekts auf [deprecated]
Beschreibung
Warnung
Die Funktion call_user_method() seit PHP 4.1.0 veraltet.
Beispiele
Beispiel #1 call_user_function() Alternative
<?php
call_user_func($array($obj, $method_name), $parameter /* , ...*/);
call_user_func($array(&$obj, $method_name), $parameter /* , ...*/); // PHP4
?>
Siehe auch
- call_user_func_array() - Call a callback with an array of parameters
- call_user_func() - Aufruf einer benutzerdefinierten Funktion
call_user_method
j dot h at h-elektro dot de
05-Feb-2007 09:11
05-Feb-2007 09:11
jonathanMAPS_ON at NO_SPAMsharpmedia dot net
13-Mar-2001 12:06
13-Mar-2001 12:06
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 at emd dot com dot br
18-Sep-2000 02:12
18-Sep-2000 02:12
This function is very similar to this:
$method="Print";
$object->$method($param1,$param2);
Note the extra $ after the ->
jmcastagnetto at php dot net
21-Aug-2000 02:04
21-Aug-2000 02:04
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