Does PHP have a method for automatically creating class variables? I think I saw something like this before, but I'm not sure.
public class TestClass { private $data = array(); public function TestClass() { $this->data['firstValue'] = "cheese"; } }
The $this->data array is always an associative array, but they vary from class to class. Is there a viable way to access $this->data['firstValue'] from $this->firstValue without specifying a link?
And if so, are there any flaws?
Or is there a static method for defining a link in a way that won't explode if the $this->data array does not contain this key?
oop php
Oli
source share