PHP 5.3: Late static binding doesn't work for properties when defined in parent class while missing in child class?

It does refer to the correct class, it's just that, unless redeclared or otherwise the reference set is broken, static properties in subclasses are in the same reference set as in the superclass So you must do: class Brother extends Mommy { protected static $_data; } or: class Brother extends Mommy { } $tmp = null; Brother::$_data =& $tmp; unset($tmp).

It does refer to the correct class, it's just that, unless redeclared or otherwise the reference set is broken, static properties in subclasses are in the same reference set as in the superclass. So you must do: class Brother extends Mommy { protected static $_data; } or: class Brother extends Mommy { } $tmp = null; Brother::$_data =& $tmp; unset($tmp).

I was able to tool your second solution so that it works from within the parent class, thus answering my question exactly. My parent class creates the property for the child class within the init method as follows: public static function init( $data ) { $calledClass = get_called_class(); $tmp = null; $calledClass::$_data =& $tmp; unset($tmp); static::$_data = $data; } – FriendlyDev Jan 2 at 6:00 And actually, I can just do this: public static function init( $data ) { $calledClass = get_called_class(); $calledClass::$_data =& $data; } – FriendlyDev Jan 2 at 6:26 As a special note, the parent class must have the property defined in order for this method to work, otherwise, if the Mommy class doesn't have $_data defined as a property, a fatal error is thrown when trying to re-point the child property's reference with $calledClass::$_data =& $data;. (It's because the child class never inherits the pointer from the parent, so it cannot reassign the pointer to anything.) This is in contrast to explicitly defining it in the child class without the workaround in place--it doesn't require it in the parent class when defining it directly in the child class.

– FriendlyDev Jan 2 at 7:43.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions