Bug #67711 [NEW]: Can't dereference constant strings
| From: | chriswarbo at gmail dot com | Date: | Tue, 29 Jul 2014 19:34:21 +0000 |
| Subject: | Bug #67711 [NEW]: Can't dereference constant strings | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-186869@lists.php.net to get a copy of this message | ||
From: chriswarbo at gmail dot com
Operating system: Linux
PHP version: 5.6Git-2014-07-29 (Git)
Package: Strings related
Bug Type: Bug
Bug description:Can't dereference constant strings
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 bug report at https://bugs.php.net/bug.php?id=67711&edit=1
--