php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #19439 reference to $this issue warning
Submitted: 2002-09-16 12:59 UTC Modified: 2002-12-29 01:00 UTC
From: kylam at superapple dot org Assigned:
Status: No Feedback Package: Scripting Engine problem
PHP Version: 4.2.3 OS: Windows 2000
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: kylam at superapple dot org
New email:
PHP Version: OS:

 

 [2002-09-16 12:59 UTC] kylam at superapple dot org
Here are two classes:
<?php
class myBase
{
    function g()
    {
        return 'haha';
    }
    function output()
    {
        $x = new myBar($this);
        echo $this->g();
    }
}


class myBar
{
    var $container;
    function myBar(&$obj)
    {
        $this->container = $obj;
    }
}

// this work
echo myBase::g();        
?>


But when I copy the code of myBase::output() method outside the class defination, without changing the reference to $this variable passed to '$x = new myBar($this)' carelessly, that is

<?php
$x = new myBar($this);
echo myBase::g();   // this issue warning
?>

PHP gives a message to me:
Warning: Problem with method call - please report this bug in xxx on line xx

It should not be a normal case to work with $this outside a class, but as the message 'define' this as a bug, I just drop a message here.

:)

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-12-08 10:51 UTC] sniper@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php4-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php4-win32-latest.zip


Can't reproduce with PHP 4.3.0-dev. Although I might have misunderstood what script actually is causing it. If it still happens with the latest snapshot, please include a really NOT working example script here.

 [2002-12-29 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over 2 weeks, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Tue Dec 06 23:03:57 2022 UTC