What is the php_binary serialization handler?

好久不见. 提交于 2019-12-18 07:45:16

问题


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

session

Registered save handlers => files user sqlite memcached
Registered serializer handlers => php php_binary wddx

I was not aware that PHP serialization supported a binary format, and there does not appear to be anything in the documentation about it.

I was going to use igbinary for session serialization to a memcached server, so I'm wondering how php_binary compares.


回答1:


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.



来源:https://stackoverflow.com/questions/6722874/what-is-the-php-binary-serialization-handler

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!