|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #67711 Can't dereference constant strings
Submitted: 2014-07-29 19:34 UTC Modified: 2016-06-14 13:10 UTC
From: chriswarbo at gmail dot com Assigned: cmb (profile)
Status: Closed Package: Strings related
PHP Version: 5.6Git-2014-07-29 (Git) OS: Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: chriswarbo at gmail dot com
New email:
PHP Version: OS:


 [2014-07-29 19:34 UTC] chriswarbo at gmail dot com
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:
define('MY_CONST', 'hello');

Expected result:
'string(1) "e"' on stdout

Actual result:
Parse error: syntax error, unexpected '[' in /home/chris/test2.php on line 5


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2014-08-01 17:21 UTC]
-Type: Bug +Type: Feature/Change Request
 [2016-06-14 13:10 UTC]
-Status: Open +Status: Closed -Assigned To: +Assigned To: cmb
 [2016-06-14 13:10 UTC]
That is possible as of PHP 5.6.0, see <>.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Jun 15 11:01:30 2024 UTC