Posted by ZabMilenko on 10/12/06 08:10
It's all about the scope.
class BlahBlah
{
const MY_CONSTANT = 45676;
}
define('MY_CONSTANT', 76344);
echo BlahBlah::MY_CONSTANT . "\n" . MY_CONSTANT;
// returns:
// 45676
// 76344
Class constants are the closest thing to namespaces as php will get for this
version.
Jason wrote:
> 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?
>
> - Jason
>
Navigation:
[Reply to this message]
|