note 62829 deleted from language.oop.serialization by nlopess

From: Date: Tue, 25 Jul 2006 20:11:52 +0000
Subject: note 62829 deleted from language.oop.serialization by nlopess
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-115179@lists.php.net to get a copy of this message
Note Submitter: zabmilenko at hotmail dot com ---- This was something that surprised me when I was testing serialization tonight. Consider the following code: <?php // Note that the only difference between the classes // is the scope of their only property. class Test1 { protected $key = 'value'; } class Test2 { private $key = 'value'; } class Test3 { public $key = 'value'; } $t1 = new Test1; $t2 = new Test2; $t3 = new Test3; echo "<pre>"; echo "Protected Size: " . strlen(serialize($t1)) . "\n"; echo "Private Size: " . strlen(serialize($t2)) . "\n"; echo "Public Size: " . strlen(serialize($t3)) . "\n"; echo "</pre>"; ?> When I executed this code on my PHP 5.1.2/WinXPHsp1/Apache2 setup, the result was the following: <?php Protected Size: 41 Private Size: 46 Public Size: 38 ?> It may be useful for you to take it into consideration, just in case.

« previous php.notes (#115179) next »