网上的解决方案:

1. 报错场景:序列化字段中有中文,反序列化时有可能会出现报错。

错误原因:写入和取出数据库的时候,编码不同,中文符号长度不同,序列化中的长度就无法匹配。

解决办法:适合 php 5.5+

//使用正则将错误的长度修正,@param $str  @return正确的序列化字符串

preg_replace_callback('#s:(\d+):"(.*?)";#s',function($match){return 's:'.strlen($match[2]).':"'.$match[2].'";';},$str);

测试依旧报错,而且并没有写入库,不符合上面报错原因-从库中读数。

将中文排除后再测试一次。

 

2. 突然想起来我的原因是,因为将file读成了base64,特别长,所以会报这个错。 

 

mark一下。

 

相关文章:

  • 2021-06-15
  • 2021-12-06
  • 2022-12-23
  • 2022-12-23
  • 2021-04-12
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-08-30
  • 2021-12-23
  • 2022-12-23
  • 2021-07-07
  • 2022-12-23
  • 2021-10-23
相关资源
相似解决方案