|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2001-03-08 05:51 UTC] zeev@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Nov 06 04:00:02 2025 UTC |
If you call a static method from within an object, the static method will inherit the $this pointer of the calling object. This script demonstrates the problem: <?php error_reporting(E_ALL); class StaticClass { function doSomething() { echo $this->data; } } class Instantiated { var $data; function Instantiated($data) { $this->data = $data; StaticClass::doSomething(); } } $ob = new Instantiated('foo'); ?> This is rather confusing behavior - $this should be out of scope inside static methods no matter what.