php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #41263 Engine treating strings as arrays
Submitted: 2007-05-03 00:56 UTC Modified: 2007-05-03 10:30 UTC
From: tachu at ezboardcorp dot com Assigned:
Status: Not a bug Package: Unknown/Other Function
PHP Version: 5.2.1 OS: 2.6.20-15-386
Private report: No CVE-ID: None
 [2007-05-03 00:56 UTC] tachu at ezboardcorp dot com
Description:
------------
When accessing a string by character offset php doesnt trigger error when going out of bounds of the string or accessing a non existing element.

Reproduce code:
---------------
<?php
$moo="asd";
var_dump($moo[444]);
var_dump($moo['cow']);
?>



Expected result:
----------------
Return false or null since the offset or index is not defined.


Actual result:
--------------
Notice: Uninitialized string offset:  444 in /home/tachu/.thunderbird/xs4vamjr.default/moo on line 3
string(0) ""
string(1) "a"


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-05-03 01:00 UTC] tachu at ezboardcorp dot com
Also doing an isset($moo['cow']) returns true.
 [2007-05-03 10:30 UTC] tony2001@php.net
That's how it works since the very beginning.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed May 08 01:01:30 2024 UTC