class sendAdminpush {
  private $db;
   function __construct()
   //importing required files 
require_once 'DbOperationF.php';
require_once 'Firebase.php';
require_once 'push.php';  
$db = new DbOperationF();

 public function sendNotificationtoAdmin($title, $message,$usertype){

      $notId = rand(10,1000);
     $sound = "notification";
     $image= "ic_waterlogo";

      //creating a new push
    $push = null; 
    $push = new Push(
        //getting the push from push object
    $mPushNotification = $push->getPush(); 

    //getting the token from database object 
    $devicetoken = $db->getAllTokens($usertype);

    //creating firebase class object 
    $firebase = new Firebase(); 
    //echo "tok:".$devicetoken."and p".$mPushNotification;
    //sending push notification and displaying result 
    echo $firebase->send($devicetoken, $mPushNotification);



   //class end


我从另一个班级打电话给sendAdminpush 但是它给出了一个错误

PHP Fatal error:  Uncaught Error: Call to a member function getAllTokens() on null in /home/ihdi/public_html/



  class DbOperationF
//Database connection link
private $conn;

//Class constructor
function __construct()

    // //Getting the DbConnect.php file
       require_once dirname(__FILE__) . '/../DbConnect.php';

    //require_once '../DbConnect.php';

    // //Creating a DbConnect object to connect to the database
     $db = new DbConnect();
    // //Initializing our connection link of this class
    // //by calling the method connect of DbConnect class
   $this->conn = $db->connect();

//getting all tokens to send push to all devices
public function getAllTokens($usertype){
        echo "ui:".$token;
    $stmt = $this->conn->prepare("SELECT token from fcm_token WHERE user_type=?");
    $stmt->bind_param("s", $usertype);

     $result = $stmt->get_result();

    $tokens = array(); 

    while($token = $result->fetch_assoc()){

        array_push($tokens, $token['token']);

    return $tokens;