Serialize in php

Reply Wed 20 Jan, 2010 02:49 am
what is the need of serialization in php?

can anyone explain ..?

Thanks in advance
  • Topic Stats
  • Top Replies
  • Link to this Topic
Type: Question • Score: 0 • Views: 2,442 • Replies: 5
No top replies

Reply Wed 20 Jan, 2010 05:09 am
Php to me at least looks more like C or at most C with classes than it does like C++ so that in a way it favors older people. I've never needed classes for anything I've done with Php so the subject hasn't come up.

In C or C++ normally to to do old-fashioned writing and reading of objects or structures of a fixed size, I'd just as soon use structures and fread/fwrite statements, to me at least that's a little bit easier to read.

The problem arises when an object contains pointers to allocated memory and objects can vary in size. C++ IO does not handle that for you; what you'd do normally would be to define << and >> operators which pick up sizes from a header of some sort and then read/write the rest of the object.

I'd assume the main point of any sort of a decent serialization system would be to handle that sort of thing without the need for such metadata in objects.
Robert Gentel
Reply Wed 20 Jan, 2010 11:49 pm
It's basically like delimiting, or a way to format structured data as a string. So you can do things like take an array and serialize it and store it with the structure as a single value. When you need it back as an array you can unserialize it.

Here is an article with more info:

0 Replies
Reply Mon 12 Apr, 2010 01:03 am
may be
Reply Wed 27 Oct, 2010 10:35 am
You can format an array data to string and insert your database,And unserialize it to an array.
Reply Thu 27 Sep, 2012 03:06 am
where serialize() comes in. You can pass an array to the function, and it will return a string that is essentially the array flattened and mashed down. You can then unserialize() it to obtain the full array once again.

$the_array = array( "Lorem", "Ipsum", "Dolor" );
$serialized = serialize($the_array);
print $serialized;
0 Replies

Related Topics

In How much time a website can be developed? - Question by aussiejumpingcastle
Webdevelopment and hosting - Question by harisit2005
Showing an Ico File - Discussion by Brandon9000
how to earn money in internet - Discussion by rizwanaraj
The version 10 bug. Worse then Y2K! - Discussion by Nick Ashley
CSS Border style colors - Question by meesa
There is no Wisdom in Crowds - Discussion by ebrown p
THANK YOU CRAVEN AND NICK!!! - Discussion by dagmaraka
I'm the developer - Discussion by Nick Ashley
  1. Forums
  2. » Serialize in php
Copyright © 2020 MadLab, LLC :: Terms of Service :: Privacy Policy :: Page generated in 0.03 seconds on 08/10/2020 at 07:24:38