File:
[ELWIX - Embedded LightWeight unIX -] /
embedaddon /
php /
ext /
standard /
tests /
serialize /
serialization_arrays_004.phpt
Revision
1.1.1.1 (vendor branch):
download - view:
text,
annotated -
select for diffs -
revision graph
Tue Feb 21 23:48:04 2012 UTC (12 years, 6 months ago) by
misho
Branches:
php,
MAIN
CVS tags:
v5_4_3elwix,
v5_4_29p0,
v5_4_29,
v5_4_20p0,
v5_4_20,
v5_4_17p0,
v5_4_17,
v5_3_10,
HEAD
php
--TEST--
serialization: arrays with references to the containing array
--FILE--
<?php
/* Prototype : proto string serialize(mixed variable)
* Description: Returns a string representation of variable (which can later be unserialized)
* Source code: ext/standard/var.c
* Alias to functions:
*/
/* Prototype : proto mixed unserialize(string variable_representation)
* Description: Takes a string representation of variable and recreates it
* Source code: ext/standard/var.c
* Alias to functions:
*/
function check(&$a) {
var_dump($a);
$ser = serialize($a);
var_dump($ser);
$b = unserialize($ser);
var_dump($b);
$b[0] = "b0.changed";
var_dump($b);
$b[1] = "b1.changed";
var_dump($b);
$b[2] = "b2.changed";
var_dump($b);
}
echo "\n\n--- 1 refs container:\n";
$a = array();
$a[0] = &$a;
$a[1] = 1;
$a[2] = 1;
check($a);
echo "\n\n--- 1,2 ref container:\n";
$a = array();
$a[0] = &$a;
$a[1] = &$a;
$a[2] = 1;
check($a);
echo "\n\n--- 1,2,3 ref container:\n";
$a = array();
$a[0] = &$a;
$a[1] = &$a;
$a[2] = &$a;
check($a);
echo "Done";
?>
--EXPECTF--
--- 1 refs container:
array(3) {
[0]=>
&array(3) {
[0]=>
*RECURSION*
[1]=>
int(1)
[2]=>
int(1)
}
[1]=>
int(1)
[2]=>
int(1)
}
string(56) "a:3:{i:0;a:3:{i:0;R:2;i:1;i:1;i:2;i:1;}i:1;i:1;i:2;i:1;}"
array(3) {
[0]=>
&array(3) {
[0]=>
*RECURSION*
[1]=>
int(1)
[2]=>
int(1)
}
[1]=>
int(1)
[2]=>
int(1)
}
array(3) {
[0]=>
string(10) "b0.changed"
[1]=>
int(1)
[2]=>
int(1)
}
array(3) {
[0]=>
string(10) "b0.changed"
[1]=>
string(10) "b1.changed"
[2]=>
int(1)
}
array(3) {
[0]=>
string(10) "b0.changed"
[1]=>
string(10) "b1.changed"
[2]=>
string(10) "b2.changed"
}
--- 1,2 ref container:
array(3) {
[0]=>
&array(3) {
[0]=>
*RECURSION*
[1]=>
*RECURSION*
[2]=>
int(1)
}
[1]=>
&array(3) {
[0]=>
*RECURSION*
[1]=>
*RECURSION*
[2]=>
int(1)
}
[2]=>
int(1)
}
string(56) "a:3:{i:0;a:3:{i:0;R:2;i:1;R:2;i:2;i:1;}i:1;R:2;i:2;i:1;}"
array(3) {
[0]=>
&array(3) {
[0]=>
*RECURSION*
[1]=>
*RECURSION*
[2]=>
int(1)
}
[1]=>
&array(3) {
[0]=>
*RECURSION*
[1]=>
*RECURSION*
[2]=>
int(1)
}
[2]=>
int(1)
}
array(3) {
[0]=>
&string(10) "b0.changed"
[1]=>
&string(10) "b0.changed"
[2]=>
int(1)
}
array(3) {
[0]=>
&string(10) "b1.changed"
[1]=>
&string(10) "b1.changed"
[2]=>
int(1)
}
array(3) {
[0]=>
&string(10) "b1.changed"
[1]=>
&string(10) "b1.changed"
[2]=>
string(10) "b2.changed"
}
--- 1,2,3 ref container:
array(3) {
[0]=>
&array(3) {
[0]=>
*RECURSION*
[1]=>
*RECURSION*
[2]=>
*RECURSION*
}
[1]=>
&array(3) {
[0]=>
*RECURSION*
[1]=>
*RECURSION*
[2]=>
*RECURSION*
}
[2]=>
&array(3) {
[0]=>
*RECURSION*
[1]=>
*RECURSION*
[2]=>
*RECURSION*
}
}
string(56) "a:3:{i:0;a:3:{i:0;R:2;i:1;R:2;i:2;R:2;}i:1;R:2;i:2;R:2;}"
array(3) {
[0]=>
&array(3) {
[0]=>
*RECURSION*
[1]=>
*RECURSION*
[2]=>
*RECURSION*
}
[1]=>
&array(3) {
[0]=>
*RECURSION*
[1]=>
*RECURSION*
[2]=>
*RECURSION*
}
[2]=>
&array(3) {
[0]=>
*RECURSION*
[1]=>
*RECURSION*
[2]=>
*RECURSION*
}
}
array(3) {
[0]=>
&string(10) "b0.changed"
[1]=>
&string(10) "b0.changed"
[2]=>
&string(10) "b0.changed"
}
array(3) {
[0]=>
&string(10) "b1.changed"
[1]=>
&string(10) "b1.changed"
[2]=>
&string(10) "b1.changed"
}
array(3) {
[0]=>
&string(10) "b2.changed"
[1]=>
&string(10) "b2.changed"
[2]=>
&string(10) "b2.changed"
}
Done
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>