[POO] Using $this when not in object context
Bonjour j'ai une erreur "Using $this when not in object context" dans ce bout de code et je ne comprend pas (la ligne concernée est en gras) :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
|
<?php
class TemplateEngine
{
private $template;
private $variables;
public function __construct($template)
{
$this->template = addslashes($template);
$this->variables = array();
}
public function addVariable($variable, $content)
{
$this->variables[$variable] = $content;
}
...
}
?> |
Je suis bien dans un "contexte objet", j'ai bien instancié mon tableau dans le constructeur, qu'est-ce qui cloche ?