angeo
answered Aug 19 '21 00:00
in PHP 7 , define() function changed so array also can be value of the constant
<?php
define("DATBASECONSTANT",array("host"=>"localhost","databasename"=>"databasename","databasepassword"=>"password"));
print_r(DATBASECONSTANT);
?>
it will print Array ( [host] => localhost [databasename] => databasename [databasepassword] => password )
array defined by define() function , it can be accessed same as array we do in PHP
<?php
define("DATBASECONSTANT",array("host"=>"localhost","databasename"=>"databasename","databasepassword"=>"password"));
echo(DATBASECONSTANT['host']);
?>
it will print : localhost