php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #31813 Bogus empty()
Submitted: 2005-02-02 14:28 UTC Modified: 2005-02-02 14:47 UTC
From: stach at chello dot pl Assigned:
Status: Not a bug Package: Arrays related
PHP Version: 4.3.10 OS: win32 (2000srv)
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: stach at chello dot pl
New email:
PHP Version: OS:

 

 [2005-02-02 14:28 UTC] stach at chello dot pl
Description:
------------
function empty returns true when the value of the variable is '0' (string).

Reproduce code:
---------------
$d['id'][0] = '0';
var_dump(empty($d['id'][0]));

Expected result:
----------------
false

Actual result:
--------------
true

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-02-02 14:39 UTC] tony2001@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

"empty() returns FALSE if var has a non-empty and non-zero value." http://php.net/empty
 [2005-02-02 14:42 UTC] stach at chello dot pl
I've found the explanation that empty() should work like this (however pre 4.3.10 empty in case like that would  return false as I would expect). 0 in a string is not an empty value, and in my opinion empty should return false in case like this. But thats my thinkin :)
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu May 16 13:01:32 2024 UTC