note 62829 added to language.oop.serialization

From: Date: Fri, 10 Mar 2006 13:20:49 +0000
Subject: note 62829 added to language.oop.serialization
Groups: php.notes 
Request: Send a blank email to php-notes+get-105196@lists.php.net to get a copy of this message
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. ---- Server IP: 216.194.113.175 Probable Submitter: 66.169.255.185 ---- X-Spam-Status: No, hits=3.3 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER, HTML_MESSAGE autolearn=no version=2.64 ---- Manual Page -- http://www.php.net/manual/en/language.oop.serialization.php Edit -- http://master.php.net/note/edit/62829 Del: integrated -- http://master.php.net/note/delete/62829/integrated Del: useless -- http://master.php.net/note/delete/62829/useless Del: bad code -- http://master.php.net/note/delete/62829/bad+code Del: spam -- http://master.php.net/note/delete/62829/spam Del: non-english -- http://master.php.net/note/delete/62829/non-english Del: in docs -- http://master.php.net/note/delete/62829/in+docs Del: other reasons-- http://master.php.net/note/delete/62829 Reject -- http://master.php.net/note/reject/62829 Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#105196) next »