Page 1 of 1

[SOLVED] Classes... again!

Posted: Fri Aug 17, 2007 8:50 am
by Defkon1
i've got this situation:

classMinor has defined method getAlfa
classMaior contains an array of classMinor objects (arrMinor)
classSuper contains an array of classMaior objects (arrMaior)

from an instance of classMaior ($this) i'm trying to do:

Code: Select all

$objMaior = $this->arrMaior[$i];

$objMinor = $objMaior->getMinor($j);   //getMinor($index) returns arrMinor($index)

$result = $objMinor->getAlfa();
but it doesn't work...

the first line should work, because if i try to echo it i have:

Code: Select all

Catchable fatal error: Object of class classMaior could not be converted to string
but the second one doesn't work correctly. The third line give back:

Code: Select all

Fatal error: Call to a member function getAlfa() on a non-object

Re: Classes... again!

Posted: Fri Aug 17, 2007 9:06 am
by superdezign
Apparently, getMinor() does not return an object. Show us that function.

Posted: Fri Aug 17, 2007 9:19 am
by Defkon1
solved... i think you'll hate me shortly... :oops:

if objMaior is an empty object, getMinor method doesn't return anything and objMinor can't be initialized...

so objMinor is not an object and getAlfa method rise exception...


thanks for wasting your time with me... :D