|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2005-08-03 15:56 UTC] derick@php.net
[2005-08-03 16:19 UTC] gerald at copix dot org
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Nov 20 12:00:01 2025 UTC |
Description: ------------ $this refers to the caller in static calls of non-static methods. If the function is correctly set as static, then $this is ok. That may be a problem as I'm provinding a library that has to be PHP4/PHP5 compliant. (in PHP4, "$this" would have not been set) Reproduce code: --------------- $obj = new Caller (); $obj->showResult (); class Caller { function showResult (){ echo StaticClass::staticCallAsOfPHP4 (); } } class StaticClass { static function staticCallAsOfPHP4 (){ return (isset ($this)) ? get_class ($this) : 'none'; } } Expected result: ---------------- "none " (because of the static call, as of PHP4) Actual result: -------------- "Caller"