php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #32536 Unserialize() and booleans
Submitted: 2005-04-01 17:09 UTC Modified: 2005-04-04 12:40 UTC
From: AxelLuttgens at swing dot be Assigned:
Status: Closed Package: Documentation problem
PHP Version: 4.3.10 OS: n/a
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: AxelLuttgens at swing dot be
New email:
PHP Version: OS:

 

 [2005-04-01 17:09 UTC] AxelLuttgens at swing dot be
Description:
------------
The docs state that unserialize() may return an integer, float, string, array or object.

But it may also return a boolean:

$bool = TRUE;
$serbool = serialize($bool);
$unserbool = unserialize($serbool);
echo $serbool, '/', gettype($unserbool), '/', $unserbool? 'TRUE': 'FALSE';
--> b:1;/boolean/TRUE

Changing TRUE to FALSE in the above yields:

--> b:0;/boolean/FALSE

The problem is that a FALSE value is by itself undistinguishable from an unserialization error, not that unserialize() cant' return a boolean.

HTH,
Axel




Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-04-01 17:14 UTC] vrana@php.net
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.

Thank you for the report, and for helping us make our documentation better.
 [2005-04-01 17:30 UTC] didou@php.net
I think we really should add the last sentence of Axel 
before closing the bug. 
 [2005-04-04 11:19 UTC] vrana@php.net
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.

Thank you for the report, and for helping us make our documentation better.

"FALSE is returned both in the case of an error and if unserializing the serialized FALSE value. This special case can be catched by comparing str parameter with serialize(false) or by catching the issued E_NOTICE."
 [2005-04-04 12:40 UTC] AxelLuttgens at swing dot be
And many thanks to both of you, vrana and didou!

Axel
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed Jul 09 16:02:26 2025 UTC