Edit report at https://bugs.php.net/bug.php?id=55132&edit=1

 ID:                 55132
 User updated by:    andre at webkr dot de
 Reported by:        andre at webkr dot de
 Summary:            String access to an expression gives parse error
 Status:             Bogus
 Type:               Bug
 Package:            Scripting Engine problem
 Operating System:   Windows 7
 PHP Version:        5.3.6
 Block user comment: N
 Private report:     N

 New Comment:

I double-checked the manual, there it says:
"Characters within strings may be accessed and modified by specifying the 
zero-based offset of the desired character after the string using square array 
brackets, as in $str[42]. [...] Strings may also be accessed using braces, as 
in $str{42}, for the same purpose."
The expression ((string)$i) obviously is a string, as confirmed by var_dump():
string(3) "123"

So I don't see which part of the manual you are referring to.


Previous Comments:
------------------------------------------------------------------------
[2011-07-04 19:01:44] fel...@php.net

Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

The syntax (...){..} is not intended to work.

------------------------------------------------------------------------
[2011-07-04 18:53:24] andre at webkr dot de

Description:
------------
As documented, "accessing variables of other types [...] using [] or {} 
silently returns NULL". Because of this it is necessary to cast an integer to 
string before string access can be done. However, this results in a parse error.

Test script:
---------------
$i = 123;

echo $i{1}; // -> empty (expected)
echo ((string)$i){1}; // -> parse error



------------------------------------------------------------------------



-- 
Edit this bug report at https://bugs.php.net/bug.php?id=55132&edit=1

Reply via email to