The unexpected behaviour is due to late static binding not implemented in php
more details here http://www.colder.ch/news/08-24-2007/28/late-static-bindings-expl.html ----- Original Message ----- From: "Calvin" <[EMAIL PROTECTED]> To: "NZ PHP Users Group" <[email protected]> Sent: Friday, October 31, 2008 4:59 PM Subject: [phpug] An OO question > > Hi all, > > I am finding difficult to understand why this isn't working... > > <?php > > abstract class A { > protected static $property = false; # Q1 > public static function method() { # Q2 > return self::$property; > } > } > > class B extends A { > protected static $property = true; # Q1 > } > > var_dump(B::method()); > > It prints False and I expect it to be True... > > Q1. Does B::$property suppose to overwrite B::$property? > Q2. when B::method() is called, shouldn't it return B::$property (even > though the method is declared in A)? > Q3. Anyways to change the code to work as my expectation? > > Thanks in advance > > - Calvin > > > > --~--~---------~--~----~------------~-------~--~----~ NZ PHP Users Group: http://groups.google.com/group/nzphpug To post, send email to [email protected] To unsubscribe, send email to [EMAIL PROTECTED] -~----------~----~----~----~------~----~------~--~---
