How static methods call private properties in php

...
class BaseModel {
    protected $field = [
        "delete_time",
        "update_time",
    ];
    
    public static function getById(){
        // $field
    }
}

Php
Aug.25,2021

static methods cannot call non-static properties.

the owner of a non-static property is an instantiated class that reinitializes its own non-static property each time the class is initialized.

while static methods are initialized only once. Therefore, non-static properties cannot be called in static methods.

Menu