2016-11-11 46 views
0

因此,當我嘗試使用PHP序列化時,此字符串顯示爲false。序列化字符串中的偏移錯誤沒有意義

我使用2個在線序列化網站。

第一次測試返回正常。就是這個網站:http://blog.tanist.co.uk/files/unserialize/

另一個網站顯示真正的問題。還是呢?我很困惑。這是這個網站:https://www.functions-online.com/unserialize.html

第一誤差我得到的是「偏移7441個字節的1095」 這恰恰是在s:6:"filter";「T」形(在該段位於第12行)

我假設它意味着由於某種原因將字符數讀爲4? 我試着替換所有字符,包括引號,以確保它們不是代表多個字節的字符的某些奇數版本。這沒有用。但如果我將「過濾器」更改爲「過濾器」,它工作。並轉移到下一個偏移量錯誤。

我已經在序列化之前嘗試了很多字符串轉換,我在網上找到的解決方案。

utf8_encode 

base64_decode 

沒有一個幫助。

這是字符串。 (從MySQL表直複製與utf8_general_ci的核對)

a:13:{i:3;a:4:{s:5:"title";s:16:"Regional Offices";s:4:"text";s:1025:"<p> 
<a href="/who-we-are/structure/conferences/alaska/">Alaska Conference of the Evangelical Covenant Church</a><br /> 
<a href="/who-we-are/structure/conferences/canada/">Evangelical Covenant Church of Canada</a><br /> 
<a href="/who-we-are/structure/conferences/central/">Central Conference</a><br /> 
<a href="/who-we-are/structure/conferences/east-coast/">East Coast Conference</a><br /> 
<a href="/who-we-are/structure/conferences/great-lakes/">Great Lakes Conference</a><br /> 
<a href="/who-we-are/structure/conferences/midsouth/">Midsouth Conference</a><br /> 
<a href="/who-we-are/structure/conferences/midwest/">Midwest Conference</a><br /> 
<a href="/who-we-are/structure/conferences/northwest/">Northwest Conference</a><br /> 
<a href="/who-we-are/structure/conferences/north-pacific/">Pacific Northwest Conference</a><br /> 
<a href="/who-we-are/structure/conferences/pacific-southwest/">Pacific Southwest Conference</a><br /> 
<a href="/who-we-are/structure/conferences/southeast/">Southeast Conference</a></p>";s:6:"filter";b:0;s:5:"class";s:1:"S";}i:4;a:4:{s:5:"title";s:9:"Translate";s:4:"text";s:614:"<div id="google_translate_element"></div><script> 
function googleTranslateElementInit() { 
    new google.translate.TranslateElement({ 
    pageLanguage: 'en', 
    gaTrack: true, 
    gaId: 'UA-2683611-22', 
    layout: google.translate.TranslateElement.InlineLayout.SIMPLE 
    }, 'google_translate_element'); 
} 
</script><script src="//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"></script> 

<p><span style="font-size:10px; line-height:11px"><br /><strong>Disclaimer</strong>: This translation may not be completely accurate as it is generated by a computer.</span><br />&nbsp;</p>";s:6:"filter";b:0;s:5:"class";s:1:"S";}i:5;a:4:{s:5:"title";s:10:"Contact Us";s:4:"text";s:920:"<p>The Evangelical Covenant Church<br /> 
8303 West Higgins Road<br /> 
Chicago, Illinois 60631<br /> 
<a href="http://www.covchurch.org/who-we-are/help/contact-us/">Contact us</a></p> 

<h3>Stay Connected</h3> 

<p><a href="http://www.facebook.com/covchurch" target="_blank"><img src="/wp-content/uploads/2013/07/ecc-facebook.png" width="35" /></a>&nbsp;&nbsp;<a href="http://www.twitter.com/cov_church" target="_blank"><img src="/wp-content/uploads/2013/07/ecc-twitter.png" width="35" /></a>&nbsp;&nbsp;<a href="http://www.instagram.com/cov_church" target="_blank"><img src="/wp-content/uploads/2013/07/ecc-instagram.png" width="35" /></a>&nbsp;&nbsp;<a href="http://www.covchurch.tv" target="_blank"><img src="/wp-content/uploads/2013/07/ecc-dottv.png" width="35" /></a>&nbsp;&nbsp;<a href="http://www.covchurch.org/subscribe" target="_blank"><img src="/wp-content/uploads/2013/07/ecc-rss.png" width="35" /></a></p>";s:6:"filter";b:0;s:5:"class";s:1:"S";}i:6;a:4:{s:5:"title";s:21:"Affiliated Ministries";s:4:"text";s:1093:"<p><a href="/affiliated/camps-retreat-center/">Camps and Retreat Centers</a><br /> 
<a href="http://www.chet.org/" target="_blank" title="CHET">CHET: Hispanic Theological Studies</a><br /> 
<a href="http://covcare.org/" target="_blank" title="CIC">Covenant Initiatives for Care</a><br /> 
<a href="http://www.covenantbenevolence.org/" target="_blank">Covenant Ministries of Benevolence</a><br /> 
<a href="/benefits/pension/">Covenant Pension Plan</a><br /> 
<a href="http://www.covenantretirement.org/" target="_blank">Covenant Retirement Communities</a><br /> 
<a href="http://www.covenanttrust.com/" target="_blank">Covenant Trust Company</a><br /> 
<a href="/affiliated/health-care-residences/">Health Care and Enabling Residences</a><br /> 
<a href="/ncp/">National Covenant Properties</a><br /> 
<a href="http://www.northpark.edu/Seminary.aspx" title="NPTS" target="_blank">North Park Theological Seminary</a><br /> 
<a href="http://www.northpark.edu" target="_blank" title="NPU">North Park University</a><br /> 
<a href="http://paulcarlson.org/">Paul Carlson Partnership</a><br /> 
</p>";s:6:"filter";b:0;s:5:"class";s:1:"S";}i:7;a:3:{s:5:"title";s:0:"";s:4:"text";s:128:"<br /><a href="http://covbooks.com" target="_blank"><img src="/wp-content/uploads/2012/01/covbooks-banner.jpg" border="0" /></a>";s:6:"filter";b:0;}i:8;a:3:{s:5:"title";s:9:"User Poll";s:4:"text";s:244:"<iframe style='width:245px; height:367px; overflow-x:hidden;' frameborder='0' name='proprofs' id='proprofs' src='http://www.proprofs.com/polls/widget/?title=whats-the-length-of-video-that-you-least-likely-to-load&theme=grey&width=237'></iframe>";s:6:"filter";b:0;}i:10;a:4:{s:5:"title";s:20:"Search CovChurch.org";s:4:"text";s:463:"<form action="http://www.covchurch.org/search-covchurch/" id="cse-search-box"><div><input type="hidden" name="cx" value="000453154239674603993:lmfbvipbnwq" /><input type="hidden" name="cof" value="FORID:11" /><input type="hidden" name="ie" value="UTF-8" /><input type="text" name="q" size="24" /><input type="submit" name="sa" value="Search" /></div></form><script type="text/javascript" src="http://www.google.com/cse/brand?form=cse-search-box&lang=en"></script>";s:6:"filter";b:0;s:5:"class";s:1:"S";}i:11;a:4:{s:5:"title";s:20:"Search CovChurch.org";s:4:"text";s:505:"<form action="http://www.covchurch.org/search-covchurch/" id="cse-search-box"> 
    <div> 
    <input type="hidden" name="cx" value="000453154239674603993:lmfbvipbnwq" /> 
    <input type="hidden" name="cof" value="FORID:11" /> 
    <input type="hidden" name="ie" value="UTF-8" /> 
    <input type="text" name="q" size="18" /> 
    <input type="submit" name="sa" value="Search" /> 
    </div> 
</form> 
<script type="text/javascript" src="http://www.google.com/cse/brand?form=cse-search-box&lang=en"></script>";s:6:"filter";b:0;s:5:"class";s:1:"S";}i:12;a:4:{s:5:"title";s:0:"";s:4:"text";s:128:"<br /><a href="http://covbooks.com" target="_blank"><img src="/wp-content/uploads/2012/01/covbooks-banner.jpg" border="0" /></a>";s:6:"filter";b:0;s:5:"class";s:1:"S";}i:13;a:4:{s:5:"title";s:0:"";s:4:"text";s:128:"<br /><a href="http://covbooks.com" target="_blank"><img src="/wp-content/uploads/2012/01/covbooks-banner.jpg" border="0" /></a>";s:6:"filter";b:0;s:5:"class";s:1:"S";}i:14;a:4:{s:5:"title";s:0:"";s:4:"text";s:424:"<a class="twitter-timeline" href="https://twitter.com/Cov_Church" data-widget-id="347782163544031232">Tweets by @Cov_Church</a> 
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+"://platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script> 
";s:6:"filter";b:0;s:5:"class";s:1:"S";}i:15;a:4:{s:5:"title";s:9:"Translate";s:4:"text";s:678:"<div id="google_translate_element"></div><script type="text/javascript"> 
function googleTranslateElementInit() { 
    new google.translate.TranslateElement({pageLanguage: 'en', layout: google.translate.TranslateElement.InlineLayout.SIMPLE, multilanguagePage: true, gaTrack: true, gaId: 'UA-2683611-22'}, 'google_translate_element'); 
} 
</script><script type="text/javascript" src="//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"></script> 
<div style="margin-top: -15px;"><span style="font-size: 10px; line-height: 11px;"> 
<strong>Disclaimer</strong>: This translation may not be completely accurate as it is generated by a computer.</span> 
</div>";s:6:"filter";b:0;s:5:"class";s:1:"S";}s:12:"_multiwidget";i:1;} 
+0

在Web表單中粘貼結果可能會導致問題,如更改行尾(CR/LF和LF),更改編碼(UTF-8 ANSI)。你是如何獲得序列化的字符串? –

+0

@Igor(如上所述,直接從具有utf8_general_ci歸類的mysql表中複製)。 –

回答

1

Error at offset 1095 of 7441 bytes實際上是正確的。這並不意味着你認爲它的意思。

開始偏移量爲62觀察這裏s:1025:"開始處開始的偏移70和據稱具有1025的長度,這意味着該字符串的閉引號應在偏移1095(70 + 1025)的字符串。 ..但事實並非如此。

錯誤是「在」偏移量1095的意義上說,唯一可能的有效值是" ...這不是那裏發現的。它實際上是11個字節,偏移量爲1084.因此,錯誤是非常正確的,儘管第一眼看起來有點反直覺。

這是一個-11字節的錯誤,並且很奇怪/方便/不是太出人意料,你會發現在你的字符串中有11個換行符,這正好解釋瞭如果\r\n被替換爲\r或只有\n,它仍然可以正確顯示但不正確。

這是怎麼回事,你需要回溯調查,但錯誤是正確的;您的序列化值已損壞/損壞/不當操作,無法再解碼。

+0

啊,所以應該是\ r \ n線下缺失?直接讀取phpmyadmin中的mysql表通常顯示換行符?或者它們是不可見的? 我試圖通過PHP輸出來獲取數據。有沒有一個PHP轉換器的功能來呈現這些缺少的linebreaks?在我序列化字符串之前? –

+0

(數據將被重新保存爲新版本,所以不用擔心舊字符串被破壞,只要我可以修復它。) –

相關問題