Page 1 of 1

How to pass an array as a defined constant prior Php7

Posted: Mon Sep 05, 2016 8:52 pm
by axew3
Php 7 - Define: "Defines a named constant at runtime. In PHP 7, array values are also accepted."

But prior PHP 7, you can maybe do this, using a constant to pass an array elsewhere with define:

Code: Select all

$to_define_array = serialize($array);
define( "DEFINEANARRAY", $to_define_array );
... and so ...

Code: Select all

$serialized = DEFINEANARRAY; // passing directly the defined constant to unserialize() will not work
	  $our_array = unserialize($serialized);