Easy Tutorial
❮ Php Eof Heredoc Php Ref Directory ❯

PHP Constant Arrays

PHP 7 New Features

In PHP 5.6, constant arrays could only be defined using const, but in PHP 7, they can be defined using define().

Example

<?php
// Using the define function to define an array
define('sites', [
   'Google',
   'tutorialpro',
   'Taobao'
]);

print(sites[1]);
?>

The output of the above program is:

tutorialpro

PHP 7 New Features

❮ Php Eof Heredoc Php Ref Directory ❯