note 94367 added to language.oop5.late-static-bindings

From: Date: Fri, 30 Oct 2009 17:02:39 +0000
Subject: note 94367 added to language.oop5.late-static-bindings
Groups: php.notes 
Request: Send a blank email to php-notes+get-162291@lists.php.net to get a copy of this message
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 ?> ---- Server IP: 69.147.83.197 Probable Submitter: 90.191.216.91 ---- Manual Page -- http://www.php.net/manual/en/language.oop5.late-static-bindings.php Edit -- https://master.php.net/note/edit/94367 Del: integrated -- https://master.php.net/note/delete/94367/integrated Del: useless -- https://master.php.net/note/delete/94367/useless Del: bad code -- https://master.php.net/note/delete/94367/bad+code Del: spam -- https://master.php.net/note/delete/94367/spam Del: non-english -- https://master.php.net/note/delete/94367/non-english Del: in docs -- https://master.php.net/note/delete/94367/in+docs Del: other reasons-- https://master.php.net/note/delete/94367 Reject -- https://master.php.net/note/reject/94367 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#162291) next »