|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2016-08-22 09:46 UTC] dams@php.net
Description: ------------ Negative offset in strings works well, except when the variable is inside another string. The error works on strings, but also on arrays with negative index in arrays. The problem also appears in previous versions of PHP, both for array and string. Test script: --------------- <?php $a = "abcde"; //$a = array( -3 => 2); //It works on arrays too. echo $a[-3]."\n"; echo "$a[-3]\n"; ?> Expected result: ---------------- c c Actual result: -------------- Parse error: syntax error, unexpected '-', expecting identifier (T_STRING) or variable (T_VARIABLE) or number (T_NUM_STRING) in test.php on line 6 PatchesPull Requests
Pull requests:
HistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2026 The PHP GroupAll rights reserved. |
Last updated: Tue Oct 06 14:00:02 2026 UTC |
echo "{$a[-3]}\n"; // Note { and } Generates the expected output: ------------------------------ c