Reply to Re: [PHP] PHP 5.0. Save classes in a session. Need help now

Your name:

Reply:


Posted by Jochem Maas on 05/12/05 16:37

Richard Lynch wrote:
> On Wed, May 11, 2005 5:19 pm, Oscar Andersson said:
>
>>Is it possibele to save a class in a session
>>
>>ex.
>>
>>$cl = new Class();
>>$SESSION['this_class'] = cl;

hello, Oscar - why don't you try it?
notice how 'Class' is a keyword so you can't name a class 'Class'
notice how if you use '$SESSION' it won't work even if you start
the session correctly... $_SESSION on the other hand will work better :-)

>
>
> Yes, but...
>
> You'd have to actually use $cl in that last line, and you need to require
^ --- notice the dollar sign?

> the file that defines the class definition *BEFORE* you start your session
> in the next page where you expect the class instance to exist.

this is true.

>
> Actually, you could maybe get away with starting the session, the loading
> the class definition, then accessing the $cl variable... But I'm not sure
> of that, because I don't use classes, and even if I did, I'd load in all

that wouldn't work - at least none of the methods would be available for use -
in affect you have an incomplete object from which you can retrieve all the
properties but not call any methods.

> the class files before I started my session, just on principle.

personally I have a Session handler class with which I can
register classes to be automatically _if_ the session is started.... ;-\

...mostly because I use lots of classes - and loading them all, everytime is
not a good idea - unless you like consistently slow pages :-)

>

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация