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
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: anton dot polonskiy at gmail dot com
New email:
PHP Version: OS:

 

 [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

Pull Requests

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-2025 The PHP Group
All rights reserved.
Last updated: Fri May 02 01:01:29 2025 UTC