Say we have the following:
some.class.php
class
{
public __construct()
{
fun_stuff();
}
}
configuration.inc
const SOMECONST = 1;
const SOMEOTHERCONST = 2;
I want to do something like this:
some.class.php
class
{
public __construct()
{
include_once(configuration.inc);
fun_stuff();
}
}
Now it works, but the constant is not defined within the class ( echo some::SOMECONST;), but rather in the global scope ( echo SOMECONST;)
I really really want to have constants in another file, as this makes a lot of sense in my case. Is there a way to declare constants in the scope of a class? I know that it is impossible to use includeseither requiresinside the class definition, so I do not understand.
source
share