Req #39915 [Opn]: Trying to access the index of an integer should throw a warning

From: Date: Fri, 09 Jan 2015 00:41:33 +0000
Subject: Req #39915 [Opn]: Trying to access the index of an integer should throw a warning
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-189805@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=39915&edit=1 ID: 39915 Updated by: ajf@php.net Reported by: thuejk at gmail dot com Summary: Trying to access the index of an integer should throw a warning Status: Open Type: Feature/Change Request -Package: Feature/Change Request +Package: *General Issues Operating System: Linux PHP Version: 5.2.0 Block user comment: N Private report: N New Comment: Related: https://bugs.php.net/bug.php?id=37676 Previous Comments: ------------------------------------------------------------------------ [2006-12-20 23:31:49] thuejk at gmail dot com Description: ------------ Trying to access the index of an integer is not a well-defined operation IMO, having no reasonable meaning. In practice in PHP, it seems to simply return null in all cases. I accidentally accessed an integer which I thought was a string. Because no error was returned it took me some time to track down the problem. Therefore, I suggest that trying to access an index on an integer should throw an E_NOTICE or E_WARNING. Reproduce code: --------------- error_reporting(E_ALL | E_STRICT); $a = 1234; //This will print "", with no error raised. echo '"'.$a[0].'"'; Expected result: ---------------- An E_NOTICE or E_WARNING. Actual result: -------------- No error raised ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=39915&edit=1

« previous php.bugs (#189805) next »