|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #33980 $this refers to the caller in static calls
Submitted: 2005-08-03 15:52 UTC Modified: 2005-08-03 16:21 UTC
From: gerald at copix dot org Assigned:
Status: Not a bug Package: Class/Object related
PHP Version: 5.0.3 OS: Linux
Private report: No CVE-ID: None
 [2005-08-03 15:52 UTC] gerald at copix dot org
$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:


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2005-08-03 15:56 UTC]
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at and the instructions on how to report
a bug at

 [2005-08-03 16:19 UTC] gerald at copix dot org
My mistake, next time I'll pay more attention to the 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 18 17:01:28 2024 UTC