Hey,
I’m using magic methods: __call, __set and __get. Actually, I’m using __call to do the work of set and get. The problem is that it’s not working when a get or set to a property is called from within a require. Let me show you what I mean:
class foo {
private $name = 'John';
public function __call($name, $args) { ... }
}
class bar extends foo {
private $check = '$20.00';
}
require_once 'bar.php';
$bar = new bar();
require_once 'html.php'; // here the issue comes in
html.php
echo $bar->getCheck();
Returns an error. Undefined property. In order for it to work, I need to define it, but then, what’s the point of the magic concept for ?
class bar extends foo {
private $check = '$20.00';
public function getCheck() {
return $this->check;
}
}
If I try to use call getCheck() outside the require, it works
require_once 'bar.php';
$bar = new bar();
require_once 'html.php'; // problem still exist here unless defined
echo $bar->getCheck(); //works perfectly
Anyone else run into this? It defeats the whole purpose of these magic methods really.