|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2013-10-22 01:11 UTC] gontijo dot douglas at gmail dot com
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 PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Nov 05 19:00:01 2025 UTC |
That actually is a documentation problem: the docs don't state that (new ArrayObject([…]))->offsetGet('undefinedIndex'); can raise a notice upon not found index.