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

Creating a function
Basically i wanna put all this code in a seperate file

Code: <?php

Help on code output
My CODE:

Code: [Select] echo "<phone>".$line["phone"].&qu

How to clone an SAP ECC using bacup tape on z/os?
We want to clone our production to a different SID using backup tape.

Required to login help
I'm trying to set up my site so users have to be logged into the forum to access the site.I've been

upload image name with extension using php
hi frds..

<input id="file1" type="file" name="file[]" &a

Preloading images
Posting this question here because I am not sure where this should belong.I am building an asp.net a

Help with php code
Hello, can anyone tell me why this php word trap fails to work,
and the trigger words get blow r

PHP Upload issue
Hi guys,

I have stumble across an interesting issue with my script and is doing my head in.

$get problem
Hi Guys ...

can you please tell me what i am doing wrong here
Code: <?php

Floating Point Precision Loss
I'm writing a program to draw a three-dimensional cube (with a corner cut off) without using any 3D

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