Static methods requiring var

Posted by Charlie Pigarelli on Stack Overflow See other posts from Stack Overflow or by Charlie Pigarelli
Published on 2011-01-04T20:19:59Z Indexed on 2011/01/04 20:54 UTC
Read the original article Hit count: 160

Filed under:
|

Ok, i'm stuck on this, why don't i get what i need?

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];
    }
}

I'm getting this:

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

And i need to call the method in this way: config::get()...

© Stack Overflow or respective owner

Related posts about php

Related posts about static