|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2004-10-13 03:28 UTC] pickwd at videotron dot ca
Description:
------------
Some on can explain me that:
<?
class B {
public $v;
}
class A {
private $v;
}
$a= new A();
$b= new B();
$sa1= 'O:1:"A":1:{s:4:"Av";N;}';//Text of serialized A
$sb1= 'O:1:"B":1:{s:1:"v";N;}';//Text of serialized B
$a1= unserialize($sa1);
$b1= unserialize($sb1);
print_r($a1);//Weird
print_r($b1);//ok B Object ( [v] => )
$sa= serialize($a);
$sb= serialize($b);
$a= unserialize($sa);
$b= unserialize($sb);
print_r($a);//ok A Object ( [v:private] => )
print_r($b);//ok B Object ( [v] => )
?>
If I serialise object with private member I'm unable unserialise it!
Reproduce code:
---------------
<?
class B {
public $v;
}
class A {
private $v;
}
$a= new A();
$b= new B();
$sa1= 'O:1:"A":1:{s:4:"Av";N;}';//Text of serialized A
$sb1= 'O:1:"B":1:{s:1:"v";N;}';//Text of serialized B
$a1= unserialize($sa1);
$b1= unserialize($sb1);
print_r($a1);//Weird
print_r($b1);//ok B Object ( [v] => )
$sa= serialize($a);
$sb= serialize($b);
$a= unserialize($sa);
$b= unserialize($sb);
print_r($a);//ok A Object ( [v:private] => )
print_r($b);//ok B Object ( [v] => )
?>
Expected result:
----------------
The print of the A unserialize
Actual result:
--------------
nothing
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Nov 01 04:00:02 2025 UTC |
You did not copy the serialized data correctly. It contains NUL chars! The following shows it: 'O:1:"A":1:{s:4:"Av";N;}' ..............^ length of property name It says length is 4 but you only gave 2 chars.