Hello everyone...
I'm little confused with defining constants in Cake.
I have a gallery of pictures that are on voting for _NUMBER_OF_HOURS
constant. In my old application that was written in pure PHP and not
Cake I had constants.php file where, all constants were defined like
this:
El 26/09/2008, a las 11:53, luigi7up escribió:
As I understood old method define(); is much better because it uses
php native way to define constants and latter on to use that constant
you just call it like this: _CONSTANT_NAME.
Configure is not intended for define constants. It's a
Benefits of using Configure:
* No collisions with other php scripts.
* Can be changed at runtime
* Easy to organize, list, group and persist related settings
Benefits of using php constants:
* Less verbose
* More efficient
On Sep 26, 10:53 am, luigi7up [EMAIL PROTECTED] wrote:
Hello
Thanks for your reply.
In practical example where you want to define number of hours you want
your gallery pictures to be on voting what would you use?
By the way is it okay to use define(); in bootstrap?
Thanks
On Sep 26, 12:09 pm, grigri [EMAIL PROTECTED] wrote:
Benefits of using
For me the difference between Configure::write() and define() comes
down to mutability. If you need to change a value at run time then
use Configure::write(). If in fact your value is a constant and will
never change during script execution, then use define. It is
semantically more correct