What does the findSerializeError function do?

I periodically wrap myself around the error unserialize(): Error at offset when unserializing data from a database. I use base64_encode \ base64_decode to smooth operations, and it worked before then, but if that fails. I found findSerializeError here, but can't figure out what it does. If I knew what he was doing, I would be able to fix serialization errors myself. I would appreciate it if someone explained to me what this function does. Here is the function code:

 function findSerializeError($data1) { echo "<pre>"; $data2 = preg_replace ( '!s:(\d+):"(.*?)";!e', "'s:'.strlen('$2').':\"$2\";'",$data1 ); $max = (strlen ( $data1 ) > strlen ( $data2 )) ? strlen ( $data1 ) : strlen ( $data2 ); echo $data1 . PHP_EOL; echo $data2 . PHP_EOL; for($i = 0; $i < $max; $i ++) { if (@$data1 {$i} !== @$data2 {$i}) { echo "Diffrence ", @$data1 {$i}, " != ", @$data2 {$i}, PHP_EOL; echo "\t-> ORD number ", ord ( @$data1 {$i} ), " != ", ord ( @$data2 {$i} ), PHP_EOL; echo "\t-> Line Number = $i" . PHP_EOL; $start = ($i - 20); $start = ($start < 0) ? 0 : $start; $length = 40; $point = $max - $i; if ($point < 20) { $rlength = 1; $rpoint = - $point; } else { $rpoint = $length - 20; $rlength = 1; } echo "\t-> Section Data1 = ", substr_replace ( substr ( $data1, $start, $length ), "<b style=\"color:green\">{$data1 {$i}}</b>", $rpoint, $rlength ), PHP_EOL; echo "\t-> Section Data2 = ", substr_replace ( substr ( $data2, $start, $length ), "<b style=\"color:red\">{$data2 {$i}}</b>", $rpoint, $rlength ), PHP_EOL; } } } 
0
php
Oct 20 '13 at 12:04 on
source share

No one has answered this question yet.

See related questions:

4270
Link. What does this symbol mean in PHP?
2414
Why shouldn't I use mysql_ * functions in PHP?
1906
How does PHP foreach work?
1387
startsWith () and endsWith () functions in PHP
1065
Link. What does this error mean in PHP?
1004
What is stdClass in PHP?
944
What are Long-Polling, Websockets, Server-Sent Events (SSE) and Comet?
923
What is the difference between public, private and protected?
704
What is the best sorting for MySQL with PHP?
408
What does the PHP keyword "var" do?



All Articles