无法反序列化字符串

时间:2012-02-01 19:01:10

标签: php serialization

有人可以告诉我为什么这个字符串不会反序列化?我已经尝试了所有的东西(striplashes,addslashes,trim等等......)

a:10:{s:8:"order_id";s:13:"9006710350464";s:5:"buyer";s:10:"1303912674";s:3:"app";s:15:"223615011031939";s:8:"receiver";s:10:"1303912674";s:6:"amount";s:2:"20";s:11:"time_placed";s:10:"1326235812";s:11:"update_time";s:10:"1326235818";s:4:"data";s:0:"";s:5:"items";a:1:{i:0;a:7:{s:7:"item_id";s:4:"1_48";s:5:"title";s:49:"I\'m Not Jesus Mommy (Full Movie) - 48 Hour Stream";s:11:"description";s:204:"This is a purcahse to watch I\'m Not Jesus Mommy on FilmDemic Movie Streaming for a period of 48 hours. Once you complete the purchase, your account will have access to watch the movie for up to 48 hours.";s:9:"image_url";s:144:"https://filmdemic.com/apps/fb-streaming/wp-main/wp-content/themes/fd-fb-stream-wpf-child/library/images/titles/slidersize/im_not_jesus_mommy.jpg";s:11:"product_url";s:46:"http://filmdemic.com/apps/fb-streaming/film-1";s:5:"price";s:2:"20";s:4:"data";s:37:"film_id=1&wp_user_id=4&view_length=48";}}s:6:"status";s:6:"placed";}

我得到“偏移量为370的952字节的错误”,但这没有意义,Stream中的“m”是第370个字节。

谢谢!

1 个答案:

答案 0 :(得分:3)

在位置324处不存在斜杠。在PHP中序列化数据使用字符计数。例如:

s:49:"I\'m Not Jesus Mommy (Full Movie) - 48 Hour Stream"

说以下引号中会有一个包含49个字符的字符串。但是如果你正确计算,在这个字符串中有一个\使得计数为50个字符。如果你试图逃避它,请解除它以解决你的问题。

在将你的product_url结束的位置844修复后,似乎还有另一个错误,它似乎缺少一个字符,可能是url中的尾部斜线,因为url长度为45个字符,但它正在期待一个长达46个字符的长网...

因此,在更正序列化数据后,我得到了这个:

  

一个:10:{S:8:" ORDER_ID&#34 ;; S:13:" 9006710350464&#34 ;; S:5:"买方&#34 ;; S:10 :" 1303912674&#34 ;; S:3:"应用&#34 ;; S:15:" 223615011031939&#34 ;; S:8:"接收机&#34 ;;小号:10:" 1303912674&#34 ;; S:6:"量&#34 ;; S:2:" 20&#34 ;; S:11:" time_placed" ; S:10:" 1326235812&#34 ;; S:11:" UPDATE_TIME&#34 ;; S:10:" 1326235818&#34 ;; S:4:"数据&# 34 ;; S:0:"&#34 ;; S:5:"项目&#34 ;;一个:1:{I:0;一个:7:{S:7:&#34 ; ITEM_ID&#34 ;; S:4:" 1_48&#34 ;; S:5:"标题&#34 ;; S:49:"我'米   不是耶稣妈妈(整部电影) - 48小时   流"; s:11:"描述&#34 ;; s:204:"这是一个观察我的不是我不是   耶稣妈妈在FilmDemic电影流媒体上播放了48小时。   完成购买后,您的帐户将有权观看   最多48部电影   。小时&#34 ;; S:9:" IMAGE_URL&#34 ;; S:144:" HTTPS://filmdemic.com/apps/fb-streaming/wp-main/wp-content/主题/ FD-FB-流WPF的儿童/库/图像/标题/ slidersize / im_not_jesus_mommy.jpg&#34 ;; S:11:" product_url&#34 ;; S:46:" HTTP: //filmdemic.com/apps/fb-streaming/film-1/";s:5:"price";s:2:"20";s:4 :"数据&#34 ;; S:37:" film_id = 1&安培; wp_user_id = 4和; view_length = 48&#34 ;;}} S:6:"状态&#34 ;; S: 6:"放置&#34 ;;}

结果导致

array (
  'order_id' => '9006710350464',
  'buyer' => '1303912674',
  'app' => '223615011031939',
  'receiver' => '1303912674',
  'amount' => '20',
  'time_placed' => '1326235812',
  'update_time' => '1326235818',
  'data' => '',
  'items' => 
  array (
    0 => 
    array (
      'item_id' => '1_48',
      'title' => 'I'm Not Jesus Mommy (Full Movie) - 48 Hour Stream',
      'description' => 'This is a purcahse to watch I\'m Not Jesus Mommy on FilmDemic Movie Streaming for a period of 48 hours. Once you complete the purchase, your account will have access to watch the movie for up to 48 hours.',
      'image_url' => 'https://filmdemic.com/apps/fb-streaming/wp-main/wp-content/themes/fd-fb-stream-wpf-child/library/images/titles/slidersize/im_not_jesus_mommy.jpg',
      'product_url' => 'http://filmdemic.com/apps/fb-streaming/film-1/',
      'price' => '20',
      'data' => 'film_id=1&wp_user_id=4&view_length=48',
    ),
  ),
  'status' => 'placed',
)