Re: note 105525 deleted from datetime.construct by salathe
| From: | Daniel P. Brown | Date: | Thu, 25 Aug 2011 18:16:05 +0000 |
| Subject: | Re: note 105525 deleted from datetime.construct by salathe | ||
| References: | 1 2 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-182726@lists.php.net to get a copy of this message | ||
I'm just glancing at it, but what part of the code is bad here?
On Thu, Aug 25, 2011 at 04:44, <salathe@php.net> wrote:
> Note Submitter: carlos dot vini at gmail dot com
> Reason: bad code
>
> ----
>
> Before version 5.3 DateTime loses the value if it's serialized. Here's a fix:
>
> class Serializable_DateTime extends DateTime {
> private $_serializedValue;
>
> public function __wakeUp() {
> parent::__construct($this->_serializedValue);
> unset($this->_serializedValue);
> }
>
> public function __sleep() {
> $this->_serializedValue = $this->__toString();
> return array('_serializedValue');
> }
> }
>
> --
> PHP Notes Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--
</Daniel P. Brown>
Dedicated Servers, Cloud and Cloud Hybrid Solutions, VPS, Hosting
(866-) 725-4321
http://www.parasane.net/