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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
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-2024 The PHP Group
All rights reserved.
Last updated: Tue Apr 16 12:01:29 2024 UTC