Skip to main content

You shouldn't be using static members:

class Templater { private array $params = array();[]; public function assign($name, $value) : self { $this->$params[$name]>params[$name] = $value;   return $this; } public function draw() { //not really sure whatdo yousomething wantwith here$this->params } } $test = (new Templater())->assign('key', 'value')->assign('key2', 'value2')->draw(); 

You shouldn't be using static members:

class Templater { private $params = array(); public function assign($name, $value) { $this->$params[$name] = $value; return $this; } public function draw() { //not really sure what you want here } } $test = new Templater()->assign('key', 'value')->assign('key2', 'value2')->draw(); 

You shouldn't be using static members:

class Templater { private array $params = []; public function assign($name, $value) : self { $this->params[$name] = $value;   return $this; } public function draw() { // do something with $this->params } } $test = (new Templater())->assign('key', 'value')->assign('key2', 'value2')->draw(); 
Source Link
Artefacto
  • 98.1k
  • 17
  • 207
  • 230

You shouldn't be using static members:

class Templater { private $params = array(); public function assign($name, $value) { $this->$params[$name] = $value; return $this; } public function draw() { //not really sure what you want here } } $test = new Templater()->assign('key', 'value')->assign('key2', 'value2')->draw();