Q on Class and EXTEND

From: Date: Wed, 03 Sep 2003 16:12:55 +0000
Subject: Q on Class and EXTEND
Groups: php.general 
Request: Send a blank email to php-general+get-161564@lists.php.net to get a copy of this message
I found a piece of code in the docs, and thought it was a way to EXTEND a Class with new properties tha cna be accessed from original Class Object. can someone tell me what I did wrong? Thx Walter ===================== <?php class THEPARENT { var $name = null; function THEPARENT( $newName ) { $this->name = $newName ; } } class THECHILD extends THEPARENT { var $abc; var $xyz = "xyz"; // NOTE: this value will be lost during unserialization function _ATOM() { // NOTE: $this->xyz is now "xyz" $this = unserialize (serialize (new THEPARENT())); // NOTE: Original value of $this->xyz is lost $this->$abc = "abc"; // Better: initialize values after ser/unser. step } } $a = new THEPARENT ('walter'); echo $a->name . '<p />'; echo $a->abc . '<p />'; ?>

« previous php.general (#161564) next »