Doc #65942 [NEW]: PHP Notice is fired if the specified $index does not exists
| From: | gontijo dot douglas at gmail dot com | Date: | Tue, 22 Oct 2013 01:11:16 +0000 |
| Subject: | Doc #65942 [NEW]: PHP Notice is fired if the specified $index does not exists | ||
| Groups: | php.doc.bugs | ||
| Request: | Send a blank email to doc-bugs+get-10510@lists.php.net to get a copy of this message | ||
From: gontijo dot douglas at gmail dot com
Operating system:
PHP version: Irrelevant
Package: Documentation problem
Bug Type: Documentation Problem
Bug description:PHP Notice is fired if the specified $index does not exists
Description:
------------
---
From manual page:
http://www.php.net/arrayobject.offsetget#refsect1-arrayobject.offsetget-returnvalues
---
It'll fire a PHP Notice if the specified $index does not exists
Test script:
---------------
<?php
// from
http://www.php.net/manual/en/arrayobject.offsetget.php#example-3971
$arrayobj = new ArrayObject(array('zero', 7, 'example'=>'e.g.'));
var_dump($arrayobj->offsetGet(1));
var_dump($arrayobj->offsetGet('example'));
var_dump($arrayobj->offsetExists('notfound'));
// added by me
var_dump($arrayobj->offsetGet('notfound')); //shouldn't return null
silently?
Expected result:
----------------
int(7)
string(4) "e.g."
bool(false)
NULL
Actual result:
--------------
int(7)
string(4) "e.g."
bool(false)
Notice: Undefined index: notfound in test.php on line 8
NULL
--
Edit bug report at https://bugs.php.net/bug.php?id=65942&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=65942&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=65942&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=65942&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=65942&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=65942&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=65942&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=65942&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=65942&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=65942&r=support
Expected behavior: https://bugs.php.net/fix.php?id=65942&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=65942&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=65942&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=65942&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=65942&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=65942&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=65942&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=65942&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=65942&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=65942&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=65942&r=mysqlcfg