This does work:
$test = new Test();
$test->blah();
class Test // extends DateInterval
{
private $foo = 0;
public function __construct() {}
public function blah()
{
echo $this->foo;
echo $this->bar;
}
public function __get($n) { echo $n; }
}
The output is, as expected, 0bar.
But as soon as I uncomment the extends DateInterval part, I get an error:
Fatal error: Test::blah(): Unknown property (foo)
This happens with PHP 5.3.2 on Linux and it does not happen with PHP 5.3.8 on Windows.
Apparently it’s a bug that got fixed in version 5.3.6 according to this and this page.
Fixed bug #52738 (Can't use new properties in class extended from DateInterval). (Stas)Seems your only option is to switch to another PHP version.