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

How to get variable value on next page
Hello friends
i am working on payentry page ..there i have this code.........

PRotect my POST DATA... FROM HTML ATTACKS
I need to like let's say

If a user submit's his Prayer and he put's <meta refresh stuf

How many users online in the last 24-hours using time()?
I'm fairly new to PHP. I have a MySQL table called 'users' and a field called 'loggedin' which is in

exclude characters from counting?
Hello, I wanted to ask if you have a string like:
Code: $my_s='ASRGREGTGTR----REGREGRE+++RRRRRR..

in php, link returns to the line
When I add a link in a php page, the link word returns to the line (as a
would do)

Examp

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

Running External Scripts
I am very new to PHP and am not even sure what I'm asking is possible. I have just installed mediaW

generating all possible random letters
hi'

how can i randomize the letters a,b,c,d,e all possible ways, and i want to print the res

Cursor statement failed with errors
Following statement failed with the errors.

cursor proj_cursor1 is (select projectID from

delete comma
HI,

How to delete "," at the end of the string.
Code: $match = 2009/02/03/a2corr

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