[SOLVED] Classes... again!

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
Defkon1
Forum Newbie
Posts: 19
Joined: Thu Aug 09, 2007 9:13 am

[SOLVED] Classes... again!

Post 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
Last edited by Defkon1 on Fri Aug 17, 2007 9:21 am, edited 1 time in total.
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Re: Classes... again!

Post by superdezign »

Apparently, getMinor() does not return an object. Show us that function.
Defkon1
Forum Newbie
Posts: 19
Joined: Thu Aug 09, 2007 9:13 am

Post 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
Post Reply