<?php
const FOOBAR = "Foo"; // Works.
const FOOBAR = array("Foo", "Bar"); // Doesn't work. Makes sense.
const FOOBAR = serialize(array("Foo", "Bar")); // Doesn't work. Okay. :\
define("FOOBAR", serialize(array("Foo", "Bar"))); // Works! The heck?
?>
PHP Parse error: syntax error, unexpected '(', expecting ',' or ';'
Why can constants be set to serialized objects when they're declared with define()
, but not with the const
keyword? What am I missing here?
(Tested with 5.3.5-1ubuntu7.2
.)