...

View Full Version : Need info on error



anotherJEK
02-27-2012, 08:18 PM
This is the error;
Fatal error: Call to protected method _VIEW::getJs() from context '' in WC_new/new.php on line 8;
following is the code


require_once('WC_php/pixViewerApp.php');
//$_NEWOBJ = new _VIEW('new');
$_NEW = new _PIX_VIEWER('new'); // _PIX_VIEWER is a subclass of _VIEW
$_NEW_SRCSCRIPT = $_NEW->getJs(); // <<< line causing error
///$_NEW_SRCSCRIPT = $_NEWOBJ->getJs(); gives the same error

I don't under stand the meaning of 'context' in this context.
further info:
This code is in a file which is required by another file.
Original file -> requires this file;

I have tried to hunt this down in my reference material but have not
found a clue.
Thanks for time and attention
JK

Fou-Lu
02-27-2012, 08:55 PM
protected methods can only be called within that class or any child classes.


class A
{
public $c;
protected function __construct($class)
{
$this->c = $class;
}
}

new A('A');

That will fail to construct object of instance A.
On the other hand:


class B extends A
{
public function __construct()
{
parent::__construct(__CLASS__);
}
}

$a = new B();
print $a->c;

Will print 'B'.

anotherJEK
02-27-2012, 09:16 PM
I think I know what the problem is.
Thank you for your time and attention;
JK



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum