php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #18309 serialize of array doesn not preserve internal pointer
Submitted: 2002-07-12 08:07 UTC Modified: 2002-07-12 08:11 UTC
From: submiturl at vaner dot com Assigned:
Status: Not a bug Package: Arrays related
PHP Version: 4.1.2 OS: WinXP
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: submiturl at vaner dot com
New email:
PHP Version: OS:

 

 [2002-07-12 08:07 UTC] submiturl at vaner dot com
When array is serialized and unserialized  the internal pointer is not preserved. that means not the exact copy of the array is created.



-------------code-----------
<?
	$array = Array();
	$array []=count($array);
	$array []=count($array);
	$array []=count($array);
	$array []=count($array);
	$array []=count($array);
	$array []=count($array);
	$array []=count($array);
	$array []=count($array);
	$array []=count($array);
	$array []=count($array);
	print_r($array);
	echo "<hr>";

	next($array);
	next($array);
	next($array);

	echo "before: ".current($array);

	$array_serialized = serialize ($array);
	unset($array);
	echo "<hr>";
	$new_array = unserialize ($array_serialized);

	echo "after".current($new_array);
?>
---------------------------
output :
Array ( [0] => 0 [1] => 1 [2] => 2 [3] => 3 [4] => 4 [5] => 5 [6] => 6 [7] => 7 [8] => 8 [9] => 9 ) 
--------------------------------------------------------------------------------
before: 3
--------------------------------------------------------------------------------
after0 

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-07-12 08:11 UTC] derick@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
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Fri Jul 03 23:01:04 2020 UTC