parent:: and this->

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
shiznatix
DevNet Master
Posts: 2745
Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:

parent:: and this->

Post by shiznatix »

I am doing some mixing up and slimming of files to make things easier to edit and keep track of. One problem I am having though is accessing some of the parents class properties. I was using this:

Code: Select all

$this->_request->getParam('variable');
but thats not going to be good for me anymore as I am using a subclass to do that work. I have tried:

Code: Select all

 
parent::_request->getParam('variable');//error unexpected T_OBJECT_OPERATOR
parent::_request::getParam('variable');//error unexpected T_PAAMAYIM_NEKUDOTAYIM
 
so how to I access a parent object variable properly in a child class?
User avatar
Kieran Huggins
DevNet Master
Posts: 3635
Joined: Wed Dec 06, 2006 4:14 pm
Location: Toronto, Canada
Contact:

Re: parent:: and this->

Post by Kieran Huggins »

Looks like a visibility issue... is it public static?

http://ca.php.net/manual/en/language.oo ... bility.php

Also, it looks fishy since it's neither a $variable, nor a function(). Is it a CONSTANT?
User avatar
shiznatix
DevNet Master
Posts: 2745
Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:

Re: parent:: and this->

Post by shiznatix »

Ya it was a visibility problem. I got a workaround going on so blah.
Post Reply