#41854 [Bgs]: Bug when php try to serialize a array with a number for key
| From: | leonardo dot celis at ohstudio dot com dot ar | Date: | Wed, 04 Jul 2007 22:37:58 +0000 |
| Subject: | #41854 [Bgs]: Bug when php try to serialize a array with a number for key | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-114655@lists.php.net to get a copy of this message | ||
ID: 41854
User updated by: leonardo dot celis at ohstudio dot com dot ar
Reported By: leonardo dot celis at ohstudio dot com dot ar
Status: Bogus
Bug Type: Session related
Operating System: Windows XP
PHP Version: 5.2.3
New Comment:
Hi!
I've a question about the reply.
Why if a array with a numeric key is serialize, when it's deserialize
works!
$var['1'] = "Hola mundo";
$x = unserialize(serialize($var));
echo serialize($var) . "<br>";
print_r($x);
But in $_SESSION doesnt?
Thanks!
Previous Comments:
------------------------------------------------------------------------
[2007-07-02 15:57:02] iliaa@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
The $_SESSION super-global cannot contain keys that are entirely
numeric
because it causes problems for register globals when every key becomes
a
variable and PHP does not allow entirely numeric variable names.
------------------------------------------------------------------------
[2007-06-29 17:36:42] leonardo dot celis at ohstudio dot com dot ar
Description:
------------
start.php: here the value is serialize, but php take the value from
memory and show it.
show.php: here the value is take from the session file and try to
unserialize. The session file have 0 bytes. Therefor the value is no
show.
However this script works:
<?
$var['1'] = "Hola mundo";
$x = unserialize(serialize($var));
echo serialize($var) . "<br>";
print_r($x);
?>
This bug I've founded with my partner Mario García.
Reproduce code:
---------------
start.php
<?
session_start();
$_SESSION['1'] = "Hola mundo";
print_r($_SESSION);
?>
show.php
<?
session_start();
print_r($_SESSION);
?>
Expected result:
----------------
Array ( [1] => Hola mundo )
Actual result:
--------------
Array ( )
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=41854&edit=1