php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #65751 isset() and empty() hides illegal offset warning
Submitted: 2013-09-24 11:03 UTC Modified: 2013-09-26 13:52 UTC
From: anton dot polonskiy at gmail dot com Assigned:
Status: Not a bug Package: *General Issues
PHP Version: Irrelevant OS: Ubuntu 13.04
Private report: No CVE-ID: None
 [2013-09-24 11:03 UTC] 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


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2013-09-26 13:52 UTC] mike@php.net
-Status: Open +Status: Not a bug
 [2013-09-26 13:52 UTC] mike@php.net
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


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon May 27 11:01:31 2024 UTC