note 94367 rejected from language.oop5.late-static-bindings by danbrown

From: Date: Fri, 30 Oct 2009 17:06:26 +0000
Subject: note 94367 rejected from language.oop5.late-static-bindings by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-162292@lists.php.net to get a copy of this message
Note Submitter: keevitaja at gmail dot com ---- why does the static::$text loose it's value? <?php class A { protected static $text; public static function init($one = '', $two = '') { $obj = new self; $obj->one = $one; $obj->two = $two; $obj->static_text = static::$text; return $obj; } public function output_text() { echo 'here shoult be some static text: ' . static::$text; } } class B extends A { protected static $text = 'this is a static text under php 5.3'; } $b = B::init('first', 'second'); echo "first: {$b->one}<br>second: {$b->two},<br>static text: {$b->static_text}<hr>"; //prints out the static_text $b->output_text(); //doesn't print out the static::text value echo '<hr>'; B::output_text(); //prints out static::$text value echo '<hr>'; $b = new B; $b->output_text(); //prints out static::$text value ?>

« previous php.notes (#162292) next »