LSB (PHP 5.3) problem with static value!


Posted on 16th Feb 2014 07:03 pm by admin

hello,

i'm having a problem. static::$text variable gets lost at some point. can someone please correct and explain it to me?
Line number On/Off| Expand/Contract <?phpclass 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}
second: {$b->two},
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?>

No comments posted yet

Your Answer:

Login to answer
85 Like 40 Dislike
Previous forums Next forums
Other forums

Change snippet to use CURDATE
I am using time() in the snippet below, I would like to use CURDATE() and have the database setup fo

Career Change into SAP
Hai
I am sajesh ,did my diploma in Mechatronics i have a 4 years of experience in

mails going in spam??
The mails I sent to folks in my database using mail(function) are going in spam??

Any idea ho

My XSRF Prevention code isn't working
First of all, thanks for the generous help you guys have given me in the past on this forum.
Seco

function not returning the correct value
I have a program that needs to return a value from a function. I have an output statement inside the

MSSQL/PHP
I am tryint to setup a webapplication developed in PHP, Apache2.0 and SQLServer2000 as backend which

Select all entries from database that include a phrase
I have a database of clubs - one of the categories is meeting time and place
I would like to have

Ball movement
I want to move a ball from one point to another and it should hit a group of balls at the other end

Preserving user-entered linebreaks
Hi, I'm building a web 2.0 thingy from scratch and I wanna display text which users input. It's all

How to grab certain words ??
I am working with this API

Returns JSON.
curl http://letsbetrends.com/api/current_trends

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash