I made a public function View() under a class Delivary(). But in line 40 I return $arr. Now it show Undefined variable: arr when my data table is empty. Notice: Undefined variable: arr in C:\xampp\htdocs\online shop\dataAccessLayer\dalDelivary.php on line 40
My code is:
class Delivary {
public $place;
public $address;
public $amount;
public $date;
public $payment;
public $walletnumber;
public $user_id;
public function DB()
{
    $connection = mysqli_connect("localhost","root","","project");
    return $connection;
}
public function Insert()
{
    $sql = "INSERT INTO delivery (place, address, amount, `date`,payment, walletnumber, user_id) VALUES 
    ('$this->place', '$this->address', '$this->amount', '$this->date', '$this->payment', '$this->walletnumber', '$this->user_id');";
    if(mysqli_query($this->DB(), $sql))
    {
        return true;
    }
        return false;
}
public function View()
{
    $sql = "SELECT delivery.delivery_id, service.area, delivery.address, delivery.amount, delivery.date, delivery.payment, delivery.walletnumber, delivery.user_id FROM delivery, service WHERE service.service_id = delivery.place";
    $result = mysqli_query($this->DB(),$sql);
    while($d = mysqli_fetch_row($result))
        {
            $arr[] = $d; 
        }
        return $arr; //line 40
}
public function Delete()
    {
        $sql = "DELETE FROM delivery WHERE delivery_id = '".$this->delivery_id."'";
        if(mysqli_query($this->DB(), $sql))
        {
            return true;
        }
        return false;
    }}
 
     
    