Re: Re: Understanding Static Methods

From: Date: Fri, 19 Nov 2004 13:00:46 +0000
Subject: Re: Re: Understanding Static Methods
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-202507@lists.php.net to get a copy of this message
On Fri, 19 Nov 2004 12:01:16 +0100, Sebastian Mendel <lists@sebastianmendel.de> wrote: > Jordi Canals wrote: > > I'm trying to understand static methods in a test class. Reading the > > manual, it says: "A member or method declared with static can not be > > accessed with a variable that is an instance of the object and cannot > > be re-defined in an extending class." > > > > Test code: > > ======== > > > > <?php > > > > class B > > { > > private $str; > > > > public final function __construct() > > { > > $this->str = 'Hello world'; > > } > > > > public function showB() > > { > > echo $this->str, '<br>'; > > echo 'Showing B<br>'; > > $this->TestStatic(); > > } > > > > > > public static function TestStatic() > > { > > echo '<br>Inside Static<br>'; > > } > > } > > > > echo error_reporting() . '<br>'; > > > > $test = new B; > > $test->TestStatic(); > > $test->showB(); > > echo "-- END --"; > > ?> > > > > Output: > > ===== > > > > 4095 > > > > Inside Static --> Called by $test->TestStatic() > > Hello world > > Showing B > > > > Inside Static --> Called from $test->showB with $this->TestStatic() > > -- END -- > > > > Comments: > > ======== > > > > I'm running PHP 5.0.2 and error_reporting = E_ALL | E_STRICT. As > > reported in the output, the values for error_reporting are well set > > (4095 == E_ALL | E_STRICT) > > with zend engine 1.3 compatiblity on ? > No, I have the zend engine 1 compatibility set to Off: zend.ze1_compatibility_mode = Off Regards, Jordi

« previous php.general (#202507) next »