How to pass an array as a defined constant prior Php7

Post a reply


This question is a means of preventing automated form submissions by spambots.
Smilies
:D :) ;) :( :o :shock: :? 8-) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :!: :?: :idea: :arrow: :| :mrgreen: :geek: :ugeek:

BBCode is ON
[img] is ON
[flash] is OFF
[url] is ON
Smilies are ON

Topic review
   

Expand view Topic review: How to pass an array as a defined constant prior Php7

How to pass an array as a defined constant prior Php7

by axew3 » Mon Sep 05, 2016 8:52 pm

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); 

print_r($our_array);

Top