Sunday, 15 September 2013

How to declare a constant with only function scope in PHP

How to declare a constant with only function scope in PHP

I'm writing a standalone function in PHP and I want to declare a constant
to prevent using a magic number. The constant does not need to be global,
which is what define()would produce; function-level scope would be the
best option. Basically, I'm looking for the equivalent of a local
finalvariable in Java.

No comments:

Post a Comment