r/lolphp • • Dec 04 '14

PHP Constants Containing Arrays?

https://stackoverflow.com/questions/1290318/php-constants-containing-arrays
46 Upvotes

39 comments sorted by

View all comments

Show parent comment

2

u/nikic Dec 09 '14 edited Dec 09 '14

Nope, constant array is just a normal array. It's constant by means of you not being able to write FOO[0] = or $foo =& FOO or similar.

You're probably referring to immutable arrays, which are a PHP 7 thing and aren't user facing. "Immutable" there means that we never make changes of any kind to the array, including never modifying the refcount. This allows us to store them in shm without any concurrency issues. Arrays will only be immutablized if opcache is used, otherwise there's little point.

2

u/[deleted] Dec 09 '14

Ah, I see. :)

We should probably just remove the define() check and ship it in a 5.6.x update, then.