php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #47053 empty($FRED) returns false incorrectly
Submitted: 2009-01-09 14:35 UTC Modified: 2009-01-18 01:00 UTC
From: mc at cowensw dot cxo dot uk Assigned:
Status: No Feedback Package: Scripting Engine problem
PHP Version: 6CVS-2009-01-09 (CVS) OS: Linux
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: mc at cowensw dot cxo dot uk
New email:
PHP Version: OS:

 

 [2009-01-09 14:35 UTC] mc at cowensw dot cxo dot uk
Description:
------------
Hosting moved to new version 8-1-2009.  Since then in certain situations the empty() function now returns wrong value.  Argument holds space, but function returns "not empty".

Tested all normal empty functions, and they are OK (http://www.dev.holidaynetwork.co.uk/Test3.php)

In this case $purchaseToken is derived from a row in a Session Variable.

I have tried to reproduce this with smaller simpler scripts, but with no success.





Reproduce code:
---------------
Sample extract from script:
echo '  purchaseToken7    >>'.$purchaseToken7.'<< <br>';
echo '  rhf    >>'.$rhf.'<< <br>';
echo '  $_SESSION["Sess_purchaseToken7"] array   >>'; print_r($_SESSION["Sess_purchaseToken7"]); echo '<< <br>';
echo '  $_SESSION["Sess_purchaseToken7"][$rhf] array   >>'.$_SESSION["Sess_purchaseToken7"][$rhf].'<< <br>';
echo '  strlen(purchaseToken7)    >>'.strlen($purchaseToken7).'<< <br>';
echo '  bin2hex(purchaseToken7)    >>'.bin2hex($purchaseToken7).'<< <br>';

if (!empty($purchaseToken7) ) echo "purchaseToken not empty<br>"; else echo "purchaseToken  empty<br>" ;
if (empty($purchaseToken7) ) echo "purchaseToken empty<br>"; else echo "purchaseToken not empty <br>";
$ShowDiag = 0;
exit()



Expected result:
----------------
Sample Output
Shows  variable purchaseToken is space,
However empty function returns "not empty"

purchaseToken7 >> << 
rhf >>9<< 
$_SESSION["Sess_purchaseToken7"] array >>Array ( [0] => 0 [1] => [2] => [3] => 0 [4] => 0 [5] => [6] => [7] => [8] => [9] => ) << 
$_SESSION["Sess_purchaseToken7"][$rhf] array >> << 
strlen(purchaseToken7) >>1<< 
bin2hex(purchaseToken7) >>20<< 
purchaseToken empty
purchaseToken empty 

Actual result:
--------------
Sample Output
Shows  variable purchaseToken is space,
However empty function returns "not empty"

purchaseToken7 >> << 
rhf >>9<< 
$_SESSION["Sess_purchaseToken7"] array >>Array ( [0] => 0 [1] => [2] => [3] => 0 [4] => 0 [5] => [6] => [7] => [8] => [9] => ) << 
$_SESSION["Sess_purchaseToken7"][$rhf] array >> << 
strlen(purchaseToken7) >>1<< 
bin2hex(purchaseToken7) >>20<< 
purchaseToken not empty
purchaseToken not empty 

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-01-10 19:48 UTC] felipe@php.net
Show us the var_dump()'s output to the variable that produces the wrong empty() return.

Thanks.
 [2009-01-18 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Apr 27 16:01:29 2024 UTC