jocarmichael.com

Php how to define constant array

Posted on 16.06.2018
Let us know if this helped you. The result of our research is this little code snippet below. Well use PHPs serialize function to make an Array look like string and this string is defined as the constant value. You can get the value of a constant by simply specifying its name.

You can also use the function constant to read a constant's value if you wish to obtain the constant's name dynamically.

Php how to define constant array
In PHP, by default a constant cannot be a container for an array. So I can use define string name, mixed value to set array of constants, but it seems that it forgot to bring also upgrade of. Based on PHP Manual we cant define a constant variable with value as array, yes we cant do that.
Php how to define constant array
Unlike with variables, you should not prepend a constant with a. Now this may throw off some developers coming from other languages perl for example where constants can contain arrays by default. Thank you for using Apple Support Communities. I deal with embedded platform Xilinx EDK, so the resources are limited. This one is the most popular and offers many solutions.

PreviousNext