note 98321 modified in function.unserialize by danbrown
| From: | danbrown@php.net | Date: | Wed, 09 Jun 2010 11:58:23 +0000 |
| Subject: | note 98321 modified in function.unserialize by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-169969@lists.php.net to get a copy of this message | ||
If you serialize date which includes a \n and then try to unserialize it will not work as a class.
Using a modification of the __unserialize fucntion
<?php
function __unserialize($sObject) {
$sObject = ereg_replace("\n", " ", $sObject);
return preg_replace('!s:(\d+):"(.*?)";!e',
"'s:'.strlen('$2').':\"$2\";'", $sObject );
}
?>
--was--
If you serialize date which includes a \n and then try to unserialize it will not work as a class.
Using a modification of the __unserialize fucntion
function __unserialize($sObject) {
$sObject = ereg_replace("\n", " ", $sObject);
return preg_replace('!s:(\d+):"(.*?)";!e',
"'s:'.strlen('$2').':\"$2\";'", $sObject );
}
http://php.net/manual/en/function.unserialize.php