FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » out of sheer curiosity...
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: out of sheer curiosity... [message #177566 is a reply to message #177562] Tue, 10 April 2012 00:25 Go to previous messageGo to previous message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma:
Senior Member
On 4/9/2012 6:27 PM, Scott Johnson wrote:
> On 4/9/2012 2:03 PM, Thomas Mlynarczyk wrote:
>> Scott Johnson schrieb:
>>
>>> What would be the reason to serialize an object other then to save it
>>> for later use, and at the time I can't really come up with a reason
>>> for that in my mind (lack of experience in this area I suppose)
>>
>> True, this seems to be the most common use case: Make the object persist
>> between different HTTP requests.
>>

Scotty, please see my reply to Thomas. Only the state persists between
requests. The behavior doesn't. This is a huge difference.

>>> Now if you are saving it for later use then the original object would
>>> no longer exist and the external resources as Jerry explained would no
>>> longer be available if not for the constructor.
>>
>> The point is that an unserialized object would usually be in a different
>> state than a "fresh" object created using the `new` operator and thus
>> require different initialization tasks to be performed. That's why
>> different magic methods exist:
>>
>> __construct(): Object is "fresh", created using `new`
>> __clone(): Object was copied from another object
>> __wakeup(): Object was unserialized
>>
>> Greetings,
>> Thomas
>>
> OK I see.
>
> I had not even thought about the need for creating the object from
> either new or from a copied version.
>

Actually, both are quite common in true OO languages such as C++, Java
or Smalltalk.

> Thanks for squeezing my brain.
>
> Scotty


--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: 5.4 windows installer.
Next Topic: Does PHP5 treat $_SERVER['PHP_AUTH_USER']) differently?
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Thu Nov 28 06:33:46 GMT 2024

Total time taken to generate the page: 0.04713 seconds