Bug #65751 [Opn->Nab]: isset() and empty() hides illegal offset warning
| From: | mike@php.net | Date: | Thu, 26 Sep 2013 13:52:29 +0000 |
| Subject: | Bug #65751 [Opn->Nab]: isset() and empty() hides illegal offset warning | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-181786@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=65751&edit=1
ID: 65751
Updated by: mike@php.net
Reported by: anton dot polonskiy at gmail dot com
Summary: isset() and empty() hides illegal offset warning
-Status: Open
+Status: Not a bug
Type: Bug
Package: *General Issues
Operating System: Ubuntu 13.04
PHP Version: Irrelevant
Block user comment: N
Private report: N
New Comment:
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
Previous Comments:
------------------------------------------------------------------------
[2013-09-24 11:03:26] anton dot polonskiy at gmail dot com
Description:
------------
Manual says:
"As of PHP 5.4 string offsets have to either be integers or integer-like strings, otherwise a
warning will be thrown. Previously an offset like "foo" was silently cast to 0."
That warning will suppressed by wrapping variable in isset() or empty();
http://3v4l.org/MEldp
Test script:
---------------
<?php
$a = 'foo';
var_dump($a['bar']); // warning
var_dump(empty($a['bar'])); // no warning
var_dump(isset($a['bar'])); // no warning
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=65751&edit=1