From 0ee8eea30405f9018644fea7a29dd05a4bab8c6f Mon Sep 17 00:00:00 2001 From: Adam Harvey Date: Sun, 1 Jun 2014 22:06:02 +0000 Subject: [PATCH] Update constants documentation for 5.6. git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@333675 c90b9560-bf6c-de11-be94-00142212c4b1 --- language/constants.xml | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/language/constants.xml b/language/constants.xml index ea99cf3dfb..6632641b41 100644 --- a/language/constants.xml +++ b/language/constants.xml @@ -70,9 +70,10 @@ define("__FOO__", "something"); Only scalar data (boolean, integer, float and string) can be contained - in constants. It is possible to define constants as a - resource, but it should be avoided, as it can cause - unexpected results. + in constants prior to PHP 5.6. From PHP 5.6 onwards, it is also possible + to define an array constant. It is possible to define + constants as a resource, but it should be avoided, as it can + cause unexpected results. You can get the value of a constant by simply specifying its name. @@ -131,7 +132,8 @@ define("__FOO__", "something"); - Constants may only evaluate to scalar values. + Constants may only evaluate to scalar values, or scalar or array values + in PHP 5.6 and later. @@ -162,6 +164,11 @@ echo Constant; // outputs "Constant" and issues a notice. const CONSTANT = 'Hello World'; echo CONSTANT; + +// Works as of PHP 5.6.0 +const ANOTHER_CONST = CONSTANT.'; Goodbye World'; + +echo ANOTHER_CONST; ?> ]]>