Visite Webhosting Latino, el site sobre alojamiento web.
#36707 : $this visibility violated - Mombu the Php Forum
Mombu the Php Forum sponsored links

Go Back   Mombu the Php Forum > Php > #36707 : $this visibility violated
User Name
REGISTER NOW! Mark Forums Read

sponsored links

1 24th May 13:42
External User
Posts: 1
Default #36707 : $this visibility violated

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

$this keyword visibility is violated if accessed from a function
external to a class. This happens in 4.*** versions, and in 5.***,
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...
public function prv() {
return $this->__prv;
function hack() {
$this->__prv = 'A very bad value!';
$foo = new Foo('A good __prv value');
print $foo->prv();

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

Actual result:
A very bad value


Edit this bug report at
  Reply With Quote

  sponsored links


Thread Tools
Display Modes

Copyright 2006 - Dies Mies Jeschet Boenedoesef Douvema Enitemaus -