How to solve this problem with call_user_func
When I call the function I have this error generated by php. Below the error.
Warning: call_user_func() expects parameter 1 to be a valid callback, function 'getChildsInMenuCount' not found or invalid function name i the line inside my files with the function
while ($Qcategories->fetch() ) { $categories_count++; $rows++; if ((!isset($_GET['cID']) && !isset($_GET['pID']) || (isset($_GET['cID']) && ((int)$_GET['cID'] === $Qcategories->valueInt('id')))) && !isset($cInfo) && (substr($action, 0, 3) != 'new')) { $category_childs = ['childs_count' => AdministratorMenu::getChildsInMenuCount($Qcategories->valueInt('id'))]; $cInfo_array = array_merge($Qcategories->toArray(), $category_childs); $cInfo = new objectInfo($cInfo_array); } The result of var_dump(__FUNCTION__); is string(20)"getChildsInMenuCount"
class AdministratorMenu { // Count how many subcategories exist in a category public static function getChildsInMenuCount($id) { $OSCOM_Db = Registry::get('Db'); $categories_count = 0; $Qcategories = $OSCOM_Db->prepare('select id from :table_administrator_menu where parent_id = :parent_id '); $Qcategories->bindInt(':parent_id', $id ); $Qcategories->execute(); while ($Qcategories->fetch() !== false) { $categories_count++; $categories_count += call_user_func(__FUNCTION__, $Qcategories->valueInt('id')); } return $categories_count; } }
call_user_func()for this?