ID:               36707
 Comment by:       judas dot iscariote at gmail dot com
 Reported By:      andreigurin at tiscali dot it
 Status:           Open
 Bug Type:         Class/Object related
 Operating System: windows xp sp2 / linux centos /
 PHP Version:      4.4.2
 New Comment:

your test results :

Fatal error: Using $this when not in object context..

and the code you mention cannot run in PHP4, since PHP doesn't have
public, private modifiers...

what are you talking about ?


Previous Comments:
------------------------------------------------------------------------

[2006-03-12 19:44:24] andreigurin at tiscali dot it

Description:
------------
$this keyword visibility is violated if accessed from a function
external to a class. This happens in 4.xxx versions, and in 5.xxx,
Tested on Window 2000, Windows Xp sp2, Linux Centos(3.7?), Red hat, and
some other Linux based systems

Reproduce code:
---------------
class Foo {
    private $__prv;
    public function __constructor($v) {
        $this->__prv = $v;
    }
    public function do_something() {
        bla bla bla...
        hack();
    }
    public function prv() {
        return $this->__prv;
    }
}
function hack() {
    $this->__prv = 'A very bad value!';
}
$foo = new Foo('A good __prv value');
$foo->do_something();
print $foo->prv();

Expected result:
----------------
Triggered error: 
bla bla bla undefined variable this in file.php on line ...
Output:
A good __prv value

Actual result:
--------------
Output:
A very bad value


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=36707&edit=1

Reply via email to