[Solved] Accessing another class’ method from within a standalone function [closed]


$db is not available within the function scope, you could

Pass $db as an argument

function func($db, $query, $params){
    return $db->db_control($query, $params);
}
$results = func($db, $query, $params);

Or

function func($query, $params){
    global $db;
    return $db->db_control($query, $params);
}
$result = func($query, $params);

Use global to make it available within the function, there’s probably other solutions too!

1

solved Accessing another class’ method from within a standalone function [closed]