VAR gerektiren statik yöntemler

0 Cevap php

Tamam, ben neden i ne gerek alamadım, bu konuda şaşırıp?

class config
{

    private $config;

    # Load configurations
    public function __construct()
    {
        loadConfig('site'); // load a file with $cf in it
        loadConfig('database'); // load another file with $cf in it
        $this->config = $cf; // $cf is an array
        unset($cf);
    }

    # Get a configuration
    public static function get($tag, $name)
    {
        return $this->config[$tag][$name];
    }
}

Ben bu alıyorum:

Fatal error: Using $this when not in object context in [this file] on line 22 [return $this->config[$tag][$name];]

Ve ben bu şekilde yöntemini çağırmanız gerekir: config::get() ...

0 Cevap