什么是php_binary序列化处理程序? [英] What is the php_binary serialization handler?

查看:287
本文介绍了什么是php_binary序列化处理程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我从CLI执行phpinfo()或php -i时,得到以下输出:

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

我不知道PHP序列化支持二进制格式,并且文档中似乎没有关于它的任何内容.

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

我打算使用 igbinary 将会话序列化到内存缓存服务器,所以我想知道 php_binary 的比较方式.

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

推荐答案

igbinary PHP扩展 确实提供了一个新的会话序列化/反序列化处理程序,该处理程序不同于PHP自己的实现,即phpphp_binary.

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

要回答您的问题:这些处理程序根本不进行比较,它们完全不同. igbinary 引入的差异记录在项目自述文件中.

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.

我假设您是在问这个问题,因为您在ig binary 和php_ binary 这两个词中找到了 binary 一词.但是,这并没有说太多.首先将phpphp_binary处理程序进行比较:

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:

php_binary会话序列化/反序列化处理程序与默认的php处理程序几乎相同.它们只是在会话中的变量名编码方式上有所不同.

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将使用名称的二进制长度在所有会话变量名称前添加前缀.当使用php时,每个变量名都带有|字符的后缀(\x7C,十进制124).据我所知,变量值的序列化完全没有区别.

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.

因此phpphp_binary处理程序之间值的序列化是相同的.

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

因此,除了会话变量名称的前/后缀几乎没有区别之外,问题实际上是询问igbinary与php序列化(在会话数据中使用)相比如何.这些差异在 igbinary自述文件中进行了概述.它很好地描述了执行的操作及其原因.

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.

如果您还希望使用igbinary序列化进行序列化/反序列化,则该扩展程序提供了两个替换功能:

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

igbinary_serializeigbinary_unserialize-像它们的php表亲一样使用.

igbinary_serialize and igbinary_unserialize - used like their php cousins.

如果您担心差异的某些细节,请询问.

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

这篇关于什么是php_binary序列化处理程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆