Home >Backend Development >PHP Tutorial >call_user_func_array cannot call the method of the parent class

call_user_func_array cannot call the method of the parent class

WBOY
WBOYOriginal
2016-07-06 13:52:43930browse

asklogic extends baselogic
asklogic has a property static::$model
which is an askmodel object
askmodel extends basemodel
but static::$model cannot call methods in basemodel

Also. . Use this method to call in __call
$data = call_user_func_array([static::$model, $method], $arguments);

Solving
Language php
Framework tp

Reply content:

asklogic extends baselogic
asklogic has a property static::$model
which is an askmodel object
askmodel extends basemodel
but static::$model cannot call methods in basemodel

Also. . Use this method to call in __call
$data = call_user_func_array([static::$model, $method], $arguments);

Solving
Language php
Framework tp

Thank you for the invitation
I haven’t used TP for a long time. I am not familiar with TP. I invited a friend of mine @白junyao for you. He is very familiar with TP. I hope he can solve your problem

public static $model Is it your own definition? Of course $model cannot be called if it is not assigned a value. It is usually written like this.

<code>class A {
    protected static $model;
    public static function getModelInstance() {
        if (empty(static::$model)) static::$model = new YourClass();
        return static::$model;
    }
}
//call
echo A::getModelInstance()->method();</code>
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn