|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2003-01-07 07:39 UTC] alan_k@php.net
[2004-02-18 16:25 UTC] phpbugs at ynx dot de
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Nov 02 21:00:02 2025 UTC |
hi, i found that the $this pointer does not always point to the current class, as it is supposted to. run the following example code: ----- class ca { function debug() { echo("ca::debug -> "); print_r($this); echo("<br>"); } } class cb { function debug() { echo("cb::debug -> "); print_r($this); echo("<br>"); } function test() { cb::debug(); ca::debug(); } } $b = new cb; $b->test(); ----- output is: cb::debug -> cb Object ( ) ca::debug -> cb Object ( ) but should'nt it be: cb::debug -> cb Object ( ) ca::debug -> ca Object ( ) it seems that when a class is called like class::methode from within another class, the this pointer points to the calling class, not the current running class!!