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

Login Control?!
I have a Web Site that uses the login control also I have set the destinationurl to the page I want

Help with forum quoting?
Hi im working on a forum and I have alomost finished it but i want a user quote system like twitter

Switch letters in message (basic cryptology)...
I am trying to switch letters around in a message for an application on my site (see here). The prob

some query on multilingual website
Hi all,

Which is the simplest and easiest method to make a website multilingual,
is it put

is this the proper use of mysql_real_escape_string() to prevent sql injections?
i was wondering is this the proper use of mysql_real_escape_string() to prevent sql injections? any

Running a cron job through PHP/Apache?!
Hello all,
I have a PHP script which makes a cron file from user input. When i try to run the cro

TimeZoneOffset
Hello,

Please i need your help. I have a system that users can use to punch in and out. This

php multiple action on submit
I have a form which says:

<form enctype='multipart/form-data' method='post' action='pr

Getting PHP to ammended the selected in option field
Hey Guys

thanks for everyones help so far. This site and its users are oozing awesomness.

Batch update record with Pagination
Hoping someone can help me with this issue I'm having, im trying to batch update records from a resu

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