note 50820 deleted from function.define by tularis
| From: | tularis@php.net | Date: | Sun, 03 Jun 2007 09:41:13 +0000 |
| Subject: | note 50820 deleted from function.define by tularis | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-127154@lists.php.net to get a copy of this message | ||
Note Submitter: Raphael Crawford-Marks
----
Notes on using serialize to store an array in a constant:
<?php
define('MYCONST','test'); //define constant with junk value
${MYCONST} = serialize(array("foo" => "bar")); //change value to serialized
array
echo "constant: ".${MYCONST};
echo "<br>";
$unserialized = unserialize(${MYCONST}); //unserialize
echo "unserialized: ".$unserialized['foo'];
?>
Note that you have to use ${} around the constant name for this to work.