In PHP is it possible to have constants with local scope? Is yes please provide a small example.
+6
A:
Yes, but only using a class.
class Foo
{
const BAR = 'hello, world';
}
print Foo::BAR;
About Kalium's comment, if you're on PHP 5.3, you can indeed also use namespaces:
namespace Foo;
const BAR = 1;
Macmade
2010-07-09 07:01:32
May also work with namespacing.
Kalium
2010-07-09 07:02:33