note 99072 added to function.serialize
| From: | andy at aplweb dot co dot uk | Date: | Mon, 26 Jul 2010 11:56:22 +0000 |
| Subject: | note 99072 added to function.serialize | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-171125@lists.php.net to get a copy of this message | ||
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.
----
Server IP: 92.48.74.199
Probable Submitter: 81.23.51.116
----
Manual Page -- http://www.php.net/manual/en/function.serialize.php
Edit -- https://master.php.net/note/edit/99072
Del: integrated -- https://master.php.net/note/delete/99072/integrated
Del: useless -- https://master.php.net/note/delete/99072/useless
Del: bad code -- https://master.php.net/note/delete/99072/bad+code
Del: spam -- https://master.php.net/note/delete/99072/spam
Del: non-english -- https://master.php.net/note/delete/99072/non-english
Del: in docs -- https://master.php.net/note/delete/99072/in+docs
Del: other reasons-- https://master.php.net/note/delete/99072
Reject -- https://master.php.net/note/reject/99072
Search -- https://master.php.net/manage/user-notes.php