Changes

Jump to: navigation, search

PHP Constants

31 bytes added, 14:26, 19 March 2009
Using a Variable as a Constant Name
== Using a Variable as a Constant Name ==
<google>ADSDAQBOX_FLOW</google>
It is not always the case that you want to ''hard-code'' a constant name into a script at the point you wish to access it. For example, you may have a general purpose script that you wish to perform tasks on any number of different constants, not just one that happen to have typed in the name for. The best way to resolve this issue is store the name of the constant in a variable. How then, would you access the value assigned to that constant? The answer is to use the PHP ''constant()'' function. The ''constant()'' function takes the name of the constant as an argument and returns the value of the constant which matches that name.

Navigation menu