Define a constant as an array or object : define « Math « PHP






Define a constant as an array or object

 
<?php 
$arr = array("apple", "orange", "pear"); 
define('MYARRAY', serialize($arr)); 
function MyTest() { 
    print_r(unserialize(MYARRAY)); 
} 

MyTest(); 
?>
  
  








Related examples in the same category

1.Constants and switch statement
2.Constants, like the names of variables, are case-sensitivebut unlike variables