序列化二叉树_序列化

序列化二叉树_序列化

序列化二叉树

Serializing is a nice way to get a string out of more complicated data structure. It's probably mostly used to sting-alize array data, although you can serialize scalar data as well.

序列化是一种从更复杂的数据结构中获取字符串的好方法。 尽管您也可以序列化标量数据,但它可能主要用于数组数据的精简处理。

The result of the serialization is no nature wonder, it's just a string that describes what is serialized and a value of the serialized ... thing.

序列化的结果自然不奇怪,它只是一个描述序列化内容和序列化...值的字符串。

The cert guide explains it all very well, I think just maybe an example of how something looks when it's serialized would have been nice. Otherwise the serialization may sound scary and mysterious.

证书指南对此进行了很好的解释,我认为也许只是一个序列化后的外观示例。 否则,序列化听起来可能令人恐惧和神秘。

Here's an example: < ?php $s = 'PHP'; echo serialize($s); ?> This prints: s:3:"PHP"; Which means:

这是一个示例:<?php $ s ='PHP'; 回声序列化($ s); ?>打印: s:3:"PHP"; 意思是:

  • 's' is a string, the type of the serialized var

    's'是一个字符串,是序列化var的类型
  • '3' is the length

    长度为“ 3”
  • 'PHP' is the value

    “ PHP”就是价值
  • ';' is a delimiter

    ';' 是定界符

A slightly more complicated example - serializing an array:

稍微复杂一点的示例-序列化数组:

< ?php $ar = array('PHP','key'=>'serialize'); echo serialize($ar); ?> The result is: a:2:{i:0;s:3:"PHP";s:3:"key";s:9:"serialize";}

<?php $ ar = array('PHP','key'=>'serialize'); 回声序列化($ ar); ?>结果是: a:2:{i:0;s:3:"PHP";s:3:"key";s:9:"serialize";}

  • 'a' means an array

    'a'表示数组
  • 'i' as in integer

    'i'为整数
  • 'i:0' is the integer key of the first element of the array, remember when you don't specify a key, PHP assigns one

    “ i:0”是数组第一个元素的整数键,请记住,当您不指定键时,PHP会分配一个

Tell your friends about this post on Facebook and Twitter

FacebookTwitter上告诉您的朋友有关此帖子的信息

翻译自: https://www.phpied.com/serializing/

序列化二叉树