You are here: Re: [PHP] Passing objects between pages « PHP « IT news, forums, messages
Re: [PHP] Passing objects between pages

Posted by "Matt Monaco" on 11/26/05 01:22

I know the functions don't need to be copied. I would like to easily
transport the objects (not the class) between pages using a form. I'm
pretty sure the serialize() function can't be avoided (otherwise all that
will be passed is a string with a value like "Object ID: #55") but how can I
get around the base64_encode() so the serialized object can be the value of
a checkbox?

$obj = new MyClass();
$obj = serialize($obj);
$obj = base64_encode($obj); //I would like to eliminate this line

<input type=checkbox name='fieldName' value='$obj'>

So on the next page I have to decode and deserialize

$obj = $_POST['fieldName'];
$obj = base64_decode($obj);
$obj = unserialize($obj);

echo $obj->member;
$obj->function();




"Unknown Unknown" <phpinfolist@gmail.com> wrote in message
news:793d90b50511251446x585d6960v61fc30d50b919856@mail.gmail.com...
Well the functions won't need to be copied, but can't you put
the properties into a MySQL or other database? Then on a page that you need
the properties you pull them from the table?

On 11/25/05, Matt Monaco <mmonaco3@jhu.edu> wrote:
>
> I mean the object itself, not the class (the file containing the class
> definition is included on all necessary pages with
> require_once("file.inc.php");
>
> I want to create an object on one page ($obj = new MyClass();) and have it
> on other pages, all members and functions intact.
>
> Matt
>
>
>
> "Unknown Unknown" <phpinfolist@gmail.com> wrote in message
> news:793d90b50511251426gf8c206by889abbe84ca8a063@mail.gmail.com...
> Do you mean passing the class statement or the vars? couldn't you format
> the
> vars into mysql and pull them?
>
> On 11/25/05, Matt Monaco <mmonaco3@jhu.edu> wrote:
> >
> > What is the best way to pass an object between pages? Currently I am
> > first
> > serializing, then doing a base64_encode, this doesn't seem entirely
> > efficient. (Especially the encode).
> >
> > I am however using the encode because I have the serialized object as
> the
> > value of a hidden form element. I can only have alphanumerics here.
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

 

Navigation:

[Reply to this 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

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