How can I pass the reference of a function to another function as an argument ? I was trying to implement a callback and I need to pass the reference of the function returnProduct
before.How do I do that ?
<?php
class Tester {
public function calculate($var_1,$var_2,$var_3) {
$product = var_3($var_1,$var_2);
echo $product;
}
public function returnProduct($var_1,$var_2) {
return $var_1*$var_2;
}
}
$obj = new Tester();
$obj->calculate(100,2,$obj->returnProduct);