note 89816 added to function.unserialize

From: Date: Tue, 24 Mar 2009 15:08:07 +0000
Subject: note 89816 added to function.unserialize
Groups: php.notes 
Request: Send a blank email to php-notes+get-152390@lists.php.net to get a copy of this message
@ chris at r3i dot it I found that your code works for sorting out single quotes, but then fails on double quotes. I found that this was a magic_quotes-related problem (frankly I think magic_quotes is a bad idea from the outset, but that's a rant for another time and place). I got my code to work as desired by using the following: <?php function mb_unserialize( $serial_str ) { if( get_magic_quotes_gpc() || get_magic_quotes_runtime() ) { $out = preg_replace('!s:(\d+):"(.*?)";!se', "'s:'.strlen(stripslashes('$2')).':\"'.stripslashes('$2').'\";'", $serial_str ); } else { $out = preg_replace('!s:(\d+):"(.*?)";!se', "'s:'.strlen('$2').':\"$2\";'", $serial_str ); } return unserialize($out); } ?> Hope it helps someone. ---- Server IP: 92.48.74.199 Probable Submitter: 81.174.140.18 ---- Manual Page -- http://www.php.net/manual/en/function.unserialize.php Edit -- https://master.php.net/note/edit/89816 Del: integrated -- https://master.php.net/note/delete/89816/integrated Del: useless -- https://master.php.net/note/delete/89816/useless Del: bad code -- https://master.php.net/note/delete/89816/bad+code Del: spam -- https://master.php.net/note/delete/89816/spam Del: non-english -- https://master.php.net/note/delete/89816/non-english Del: in docs -- https://master.php.net/note/delete/89816/in+docs Del: other reasons-- https://master.php.net/note/delete/89816 Reject -- https://master.php.net/note/reject/89816 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#152390) next »