任何人都能告诉我以下代码有什么问题吗?在反序列化该字符串时,我得到布尔值false:
a:3:{s:10:"Subscriber";O:14:"SubscriberType":8:{s:14:"organizationid";s:3:"omm";s:5:"jobid";s:13:"4f27d819d9fd2";s:8:"sequence";s:8:"42781971";s:20:"SubscriberTypedate";s:10:"2012-01-31";s:20:"SubscriberTypetime";s:8:"04:01:29";s:9:"timestamp";s:19:"2012-01-31T04:01:29";s:20:"SubscriberTypecert";s:46:"omm^4f27d819d9fd2^42781971^2012-01-31T04:01:29";s:11:"certificate";s:32:"ab673e29e0eb69a62b39781cdbec6368";}s:8:"Activity";O:12:"ActivityType":6:{s:5:"title";s:6:"ethics";s:8:"provider";s:21:"O'Melveny & Myers LLP";s:6:"format";s:2:"11";s:10:"completion";s:10:"2012-01-12";s:11:"description";s:35:"some's : test description here";s:7:"credits";s:17:"some credits here";}s:4:"Code";s:8:"SMH10634";}
我正在使用以下代码来序列化数据:
$stype = new SubscriberType($data1['OrgID'],$data1['OrgKey']);
$atype = new ActivityType($rdata['Title'],$data1['Provider'],$rdata['Format'],$rdata['Completion'],$rdata['Description'],$rdata['Credits']);
$repData = htmlentities(serialize(array("Subscriber"=>$stype,"Activity"=>$atype,"Code"=>$data2['ClientCode'])),ENT_QUOTES);
$sql = "insert into table values(compress('$repData'))";
以下代码将其反序列化。
$sql = "select uncompress(RepData) as RData from table";
$rData = unserialize(html_entity_decode($data['RData']));
答案 0 :(得分:0)
我希望你只使用serialize()
和unserialize()
。
当我运行它时,我收到Error at offset 169 of 700 bytes
。您应编码特殊字符和转义引号。这是如何 - > http://davidsword.ca/unserialize-error-at-offset/