Revisiting PHP: Part V: Array Constants Declaration using define ()

Image result for php array constants declaration

                                                                                Image Credits: Cloud-ways

PHP version 5.6 gave light to the define() function which was largely used for declare class or object level variables. However, with the advent of PHP 7, Array program structures can now be declared with define () function, which previously could only be declared with the const keyword function.

Take for instance:


define(‘coding_languages’, [









echo coding_languages[4]; // outputs “swift”