|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2005-07-25 23:50 UTC] helly@php.net
[2005-07-26 00:14 UTC] sr at brightlight dot ch
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Oct 29 07:00:01 2025 UTC |
Description: ------------ If a method is called via object::method(); from within a class method, then inside of the object::method(); the $this from the calling class method is visible. This makes it almost impossible to tell if a method was invoked via -> or :: Reproduce code: --------------- <?php $test = new testclass(); $test->test(); class testclass { function test() { otherclass::staticFunction(); normalFunction(); } } class otherclass { function staticFunction() { echo "staticFunction: ".(isset($this) ? "set and of class: ".get_class($this)."\n" : "not set\n"); } } function normalFunction() { echo "normalFunction: ".(isset($this) ? "set and of class: ".get_class($this)."\n" : "not set\n"); } ?> Expected result: ---------------- staticFunction: not set normalFunction: not set Actual result: -------------- staticFunction: set and of class: testclass normalFunction: not set