May 11
28
In this post you will see a example of using call_user_func_array (from PHP) to call a simple function, a public static method from a class and a public method.
First I define one function and one class:
-
function add($p1, $p2){
-
return $p1 + $p2;
-
}
-
-
class CSimpleMath{
-
function __construct($v1) {
-
}
-
-
return $a * $b;
-
}
-
-
public function substract($a, $b){
-
return $b – $a;
-
}
-
-
function __destruct() {
-
}
-
}
Maybe you notice that in the class I did inserted a construct and destruct functions. You dont realy need them for this example to work but I always include them when I write a class.
Call a simple function with call_user_func_array:
Call a public static method:
Call a public class method
