|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2002-10-25 12:03 UTC] derick@php.net
[2002-10-25 12:53 UTC] dougqh at incogen dot com
[2004-04-25 18:12 UTC] helly@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Dec 06 01:00:01 2025 UTC |
Here is an example ... <?php class Foo { function Foo() { $this->class = 'foo'; } function doCall() { return Bar::staticFunction(); } }; class Bar { function staticFunction() { if ( isset( $this ) ) { print 'This isset <br />'; print_r( $this ); } else { print 'Call as a static <br />'; } } }; $foo =& new Foo(); $foo->doCall(); ?> Note an instance of Foo is calling a static method of Bar. Bar does a test to see if $this is set. $this should not be set, since the method was statically invoked. Unfortunately, $this is set and its the instance of Foo that made the call to the static method of Bar. This bug makes writing methods that work both as static methods and instance methods virtually impossible. It is also extremely unsafe to allow Bar to access the member variables of Foo.