Bug #73143 [Opn->Nab]: The string used as an array make syntax error

From: Date: Thu, 22 Sep 2016 10:32:35 +0000
Subject: Bug #73143 [Opn->Nab]: The string used as an array make syntax error
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-204184@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=73143&edit=1

 ID:                 73143
 Updated by:         requinix@php.net
 Reported by:        442958506 at qq dot com
 Summary:            The string used as an array make syntax error
-Status:             Open
+Status:             Not a bug
 Type:               Bug
 Package:            Output Control
 Operating System:   all
 PHP Version:        5.6.26
 Block user comment: N
 Private report:     N

 New Comment:

PHP is casting 'id' to an integer so it will output $a[0]. If you try $a["1.5"]
then you will get the warning and PHP will output $a[1].


Previous Comments:
------------------------------------------------------------------------
[2016-09-22 10:27:30] 442958506 at qq dot com

Description:
------------
The string used as an array, anyway the key(string) is, the result is the first character of the
string.


Test script:
---------------
$a = '844';
echo $a['id']; 



Expected result:
----------------
PHP Warning:  Illegal string offset 'id' in E:\xx\index.php on line 3
Warning: Illegal string offset 'id' in E:\xx\index.php on line 3
result: ''

Actual result:
--------------
PHP Warning:  Illegal string offset 'id' in E:\xx\index.php on line 3
Warning: Illegal string offset 'id' in E:\xx\index.php on line 3
result: 8


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



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


Thread (2 messages)

« previous php.bugs (#204184) next »