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 all server headers like Live http Headers does
Hey all, like many of you I use the Firefox addon "Live http Headers". I'm trying to write

Hi, explode and strstr.
Hi, I seem to be confused about the strstr function, eg. i have a string like:
"a.b.c.d.e.f&

Show specific day of the week
I have been racking my brain trying to get this function to work properly and it is doing so for eve

query help
Hi experts.

i have a table rep2 like this
PROD_COD ACCT_NO DUE_DAYS BALANCE

Is it possible to view php source code??
Hi All

I was just wondering if it's possible to view a websites php source code?
I know

I face problems to extract data from one table and insert it in another one
Hi,

For modifications, I have to extract data from one table and insert it in another one

Taxonomy? Classification? Categorisation?
Not sure if there is a way around this classification problem
I have a supplier who produces

Ajax Issues - Update Panel / Timer. Intellisense doesn't know about them
Type 'System.Web.UI.ScriptManager' does not have a public property named 'UpdatePanel'. That is wha

this code is not working????
it says this error.. Warning: Division by zero in ..

the variables are correct, so why is th

Update Myspace status with CURL
Logging in:

Code: <?php

class Myspace
{
function login($username, $pa

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