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
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: 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

Pull Requests

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 Oct 31 23:01:28 2024 UTC