Ok, je suis coincé là-dessus, pourquoi n'ai-je pas ce dont j'ai besoin?Méthodes statiques nécessitant var
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];
}
}
Je reçois ceci:
Fatal error: Using $this when not in object context in [this file] on line 22 [return $this->config[$tag][$name];]
et je dois appeler la méthode de cette façon: config::get()
...
Les fonctions statiques sont appelées dans le contexte de la classe et ne font référence à aucune instance particulière. – zzzzBov