Welcome Guest, Not a member yet? Register   Sign In
Accessing constants defined in models
#1

[eluser]srisa[/eluser]
Hello,

If I define a constant in a model as const REL = 1;, how do I access that constant from outside the model?

I just ran a test, I can access it as className::const. Assuming my model is define as
class Options extends Model{
const REL = 1;
}

In the controller I am referring to that constant like this
$this->load->model('options');
echo 'constant is '.Options::REL.'<br />';

Is that acceptable or is there a better way of doing this?

Thank you.
#2

[eluser]kirrie[/eluser]
http://www.php.net/manual/en/language.oo...stants.php
#3

[eluser]manilodisan[/eluser]
I see nothing wrong...
#4

[eluser]srisa[/eluser]
Thank you.




Theme © iAndrew 2016 - Forum software by © MyBB