Reply to Re: Difference between 'const' and 'define()'

Your name:

Reply:


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
>

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация