Req #67711 [Opn->Csd]: Can't dereference constant strings
| From: | cmb@php.net | Date: | Tue, 14 Jun 2016 13:10:21 +0000 |
| Subject: | Req #67711 [Opn->Csd]: Can't dereference constant strings | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-201605@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=67711&edit=1
ID: 67711
Updated by: cmb@php.net
Reported by: chriswarbo at gmail dot com
Summary: Can't dereference constant strings
-Status: Open
+Status: Closed
Type: Feature/Change Request
Package: Strings related
Operating System: Linux
PHP Version: 5.6Git-2014-07-29 (Git)
-Assigned To:
+Assigned To: cmb
Block user comment: N
Private report: N
New Comment:
That is possible as of PHP 5.6.0, see <https://3v4l.org/lWqe0>.
Previous Comments:
------------------------------------------------------------------------
[2014-07-29 19:34:19] chriswarbo at gmail dot com
Description:
------------
Strings can be dereferenced to get sub-strings of length 1, eg. 'hello'[1] ===
'e'.
String variables can be dereferenced, eg. ($x = 'hello') && ($x[1] ===
'e')
String constants can't be dereferenced, eg. define('MY_CONST', 'hello')
&& MY_CONST[1].
Test script:
---------------
<?php
define('MY_CONST', 'hello');
var_dump(MY_CONST[1]);
Expected result:
----------------
'string(1) "e"' on stdout
Actual result:
--------------
Parse error: syntax error, unexpected '[' in /home/chris/test2.php on line 5
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=67711&edit=1