Possible Duplicate:
Getting static property from a class with dynamic class name in PHP
Take a quick look before you are going to reading my question:
In PHP we can:
Code:
<?php
class Foo
{
const TOUCH_ME = 1;
public function __construct()
{
}
}
$class = 'Foo';
$object = new $class();
$type = $object instanceof Foo;
echo $type;//Expect to 1
?>
Output:
1
And my question is, how can I do:
Code:
<?php
class Foo
{
const TOUCH_ME = 1;
public function __construct()
{
}
}
$class = 'Foo';
$var = $class::TOUCH_ME;
?>
Output:
An error
So, how can I do that? Or am I stupid?
I’m on PHP version 5.3, but I don’t see why this wouldn’t work in earlier versions of PHP unless it was an issue wrapped up with late static binding:
http://www.php.net/manual/en/language.oop5.late-static-bindings.php