Say we have the following:
some.class.php
class
{
public __construct()
{
fun_stuff();
}
}
configuration.inc
const SOMECONST = 1;
const SOMEOTHERCONST = 2;
I am looking to do something like this:
some.class.php
class
{
public __construct()
{
include_once(configuration.inc);
fun_stuff();
}
}
Now this works, but the constant is not defined within the scope of the class (echo some::SOMECONST;
) but rather in the global scope (echo SOMECONST;
)
I really really want to have the constants in another file as it makes a lot of sense in my case. Is there a way to declare the constants in the scope of the class? I know it's impossible to use includes
or requires
inside the class definition so i'm at a loss.