|
Posted by Kimmo Laine on 10/12/06 08:05
"Jason" <jason.m.ho@gmail.com> wrote in message
news:1160632390.133553.293300@i3g2000cwc.googlegroups.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
spam@outolempi.net | rot13(xvzzb@bhgbyrzcv.arg)
Navigation:
[Reply to this message]
|