开发者

An unknown data representation notation in drupal

开发者 https://www.devze.com 2023-01-28 21:35 出处:网络
s:17:\"thumbnail\"; s:1:\"1\"; a:0:{} a:9:{s:5:\"title\";s:2:\"-5\";s:10:\"body_field\";s:1:\"0\";s:20:\"revision_information\";s:1:\"3\";s:6:\"author\";s:1:\"2\";s:7:\"options\";s:1:\"4\";s:4:\"menu\
s:17:"thumbnail";
s:1:"1";
a:0:{}
a:9:{s:5:"title";s:2:"-5";s:10:"body_field";s:1:"0";s:20:"revision_information";s:1:"3";s:6:"author";s:1:"2";s:7:"options";s:1:"4";s:4:"menu";s:2:"-1";s:4:"path";s:1:"5";s:12:"image_attach";s:2:"-4";s:13:"path_redirect";s:1:"6";}

What is the name of this notation? Who is responsible for its standardiza开发者_C百科tion?


It is the PHP function serialize called internally by drupal_write_record that is responsible for this notation.


Per line:

  • the first part ("s" or "a" in your example) is the type ("s" is string, "a" is array)

  • the second part is the length (however "thumbnail" is only 9 chars, I wonder why it says s:17, there are probably extra empty chars)

  • the third part is the value as string (or as object if it's an array or an object)


More specifically, the serialize function is actually called internally by Drupal using the schema API automatically. A field can be set as "serialized" and Drupal will internally handle the conversions of arrays and objects.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号