This's my code:
$array = array(
'id' => 1,
'name' => 'Paul',
'current_job' => 'coder'
);
$interface = 'interface PropertyInterface {';
foreach ($array as $key => $value) {
$interface .= 'const '.strtoupper($key).' = '.$value.';';
}
$interface .= '}';
eval($interface);
class Foo implements PropertyInterface
{
}
when running:
var_dump(Foo::ID);
it working, return 1, but when running:
var_dump(Foo::NAME);
or:
var_dump(Foo::CURRENT_JOB);
it not working, this is error:
Use of undefined constant toan - assumed...
what's wrong? somebody can help me?