"Jason" <ja********@gmail.comwrote in message
news:11**********************@i3g2000cwc.googlegro ups.com...
What is the difference between 'const' and 'define()' ? When would I
prefer using 'const' over 'define', or vice versa? It seems if i do:
const secondsInMinute = 60;
define("secondsInMinute", 60);
Aren't these two the same thing?
const defines a class constant, while define defines a global constant. You
use const-defined constants inside class using self::constant, not
$this->constant, and a define-defined constant in a normal, non-object shit.
When using const, the value must be a static value, not a result of a
mathematical operation or function. const is restricted in many ways
compared to define, and should be used in classes/objects
--
"Ohjelmoija on organismi joka muuttaa kofeiinia koodiksi" - lpk
http://outolempi.net/ahdistus/ - Satunnaisesti päivittyvä nettisarjis
sp**@outolempi.net | rot13(xv***@bhgbyrzcv.arg)