What is the php_binary serialization handler?

前端 未结 1 652
误落风尘
误落风尘 2020-12-20 15:59

When I do phpinfo() or php -i from the CLI, I get the following output:

session

Registered save handlers => files user sqlite memcached
Registered serial         


        
相关标签:
1条回答
  • 2020-12-20 16:46

    The igbinary PHP extension does offer a new session serialize/deserialize handler that differs from PHP's own implementations, namely php and php_binary.

    To answer your question: These handlers do not compare at all, they are totally different. The differences igbinary introduces are documented within the projects readme.

    I assume you're asking the question because you found the word binary within the two: igbinary and php_binary. However that's not saying much. Compare the php with the php_binary handler first:

    The php_binary session serialize/deserialize handler is nearly identical with the default php handler. They differ only how the variable names that are within the session are encoded.

    php_binary will prefix all session variable names with the binary length of the name. While with php each variable name has a suffix of the | character (\x7C, decimal 124). From what I know, the serialization of the variable's values does not differ at all.

    So the serialization of values is identical between the php and php_binary handler.

    So next to the little difference in pre-/suffix of session variable names, the question actually asks about how does igbinary compare with php serialization (which is used in the session data). Those differences are outlined in the igbinary readme. It fairly well describes what's done and why.

    If you like to use igbinary serialization as well for serialize/unserialize, the extension offers two replacement functions:

    igbinary_serialize and igbinary_unserialize - used like their php cousins.

    If you are concerned about some specifics of the differences, please ask.

    0 讨论(0)
提交回复
热议问题