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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: tachu at ezboardcorp dot com
New email:
PHP Version: OS:

 

 [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

Pull Requests

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-2025 The PHP Group
All rights reserved.
Last updated: Sun Jul 13 15:01:33 2025 UTC