By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,963 Members | 1,061 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,963 IT Pros & Developers. It's quick & easy.

Using Zend and Object property/functions follow-up

P: n/a
Using Zend and Object property/functions follow-up:

With Zend, using PHP5, I am trying to acess property of an object that
is stored in a member variable.
I'm quite new in using PHP5 and class functions but I haven't seen
anything that could answer me. Would someone please tell me what I am
doing wrong or link me to somewhere I may find some help please

Neko
DEMO:

class A
{

private $m_oObjectC = NULL;

function __construct()
{
$this->m_oObjectC = new B();
}

private function test()
{
// I canot see the attribute listing at the second ->
as if it could not read property.
// I know that like that, there is no way it may know
what is the current object
// but this is what my question is about, how to 'CAST'

// or whatever it take to get the class information.
$var = $this->m_oObjectC->FctClassC();
}
}

class B
{

function __construct()
{
$oObjectC = new C();

// Some manipulations

return $oObjectC;
}

}

class C
{

function __construct()
{

}

function FctClassC()
{
// Some manipulations
}

}

Jun 21 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Hello,
class A
$var = $this->m_oObjectC->FctClassC();
you are trying to access method FctClassC() in Class B,
but Class B has not that method
class B
$oObjectC = new C();


in constructor you are initialising local variable
$oObjectC, it's can't be accessed from anywhere
after constructor finished

Solution:
1. change class B declaration on: Class B extends C
2. in constructor class B change: $this->oObjectC = new C();

Read about OOP.

I hope it's help.
--
Best Regards,
Juliusz
http://www.jetfish.net
Jun 22 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.