note 99072 deleted from function.serialize by danbrown
| From: | danbrown@php.net | Date: | Mon, 26 Jul 2010 14:30:04 +0000 |
| Subject: | note 99072 deleted from function.serialize by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-171130@lists.php.net to get a copy of this message | ||
Note Submitter: andy at aplweb dot co dot uk
----
A better approach than the solution by 'travis at travishegner dot com' is to make sure a
string is safe to insert into a postgres database by using a simple replace statement once the
serialize is done...
<?php
//this replace the null character with a safe representation
$safeStr = str_replace("\0", '�', serialize($obj));
$newObj = unserialize($safeStr);
?>
This means that no additional escaping is needed and yet the object maintains itself.