English 中文(简体)
PHP 7 - Constant Arrays
  • 时间:2024-12-22

PHP 7 - Constant Arrays


Previous Page Next Page  

Array constants can now be defined using the define() function. In PHP 5.6, they could only be defined using const keyword.

Example

<?php
   //define a array using define function
   define( animals , [
       dog ,
       cat ,
       bird 
   ]);
   print(animals[1]);
?>

It produces the following browser output −

cat
Advertisements