For Programmers: Free Programming Magazines  


Home > Archive > PHP Programming > July 2004 > Array of Objects in session, is it possible to access member functions?









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Array of Objects in session, is it possible to access member functions?
college

2004-07-28, 8:57 pm

I am trying to pass an array of user objects in session and take the
array out of session and call the member functions of each object.
However I am getting a Fatal error: Call to a member function on a
non-object. I have session.autostart turned off, and I have the
class definition for those objects included before the call to
session_start(). I am on PHP 4.2.3. Is this possible to do? While
debugging, it appears that the objects in the array are only seen as a
type of standard "object", and that I can only access the member
variables of the object. I tried casting to the user defined class,
but this does not see to work. Is there a way to pull these objects
out of an array that was in the session, and call the member functions
of these objects?
Phil Roberts

2004-07-28, 8:57 pm

collegeguys4@yahoo.com (college) emerged reluctantly from the
curtain and staggered drunkenly up to the mic. In a cracked and
slurred voice he muttered:

> Is there a way to pull these objects
> out of an array that was in the session, and call the member
> functions of these objects?


Not unless the objects were serialized first.

See http://www.php.net/serialize

--
Phil Roberts | Deedle Doot Doo Dee Dee | http://www.flatnet.net/
This global evolutionist conspiracy of evil athiests can kiss
my ass! Wheres my goddamn cheque??
rush

2004-07-29, 3:56 pm

"college" <collegeguys4@yahoo.com> wrote in message
news:8da449c8.0407281305.50bf212d@posting.google.com...
> I am trying to pass an array of user objects in session and take the
> array out of session and call the member functions of each object.
> However I am getting a Fatal error: Call to a member function on a
> non-object. I have session.autostart turned off, and I have the
> class definition for those objects included before the call to
> session_start(). I am on PHP 4.2.3. Is this possible to do? While
> debugging, it appears that the objects in the array are only seen as a
> type of standard "object", and that I can only access the member
> variables of the object. I tried casting to the user defined class,
> but this does not see to work. Is there a way to pull these objects
> out of an array that was in the session, and call the member functions
> of these objects?


yes but, the class of the object in the question should also be defined in
the code that is executing the function call.

--
http://www.templatetamer.com/


Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2010 codecomments.com