🔍

首页Home › 开发工具Developer Tools

🐘 PHP 序列化/反序列化PHP Serialize / Unserialize

PHP serialize() 数据与 JSON 互转:把 a:2:{…} 这样的序列化字符串还原成可读的 JSON,或把 JSON 生成 PHP 序列化字符串;也能解析 PHP Session 文件内容。Convert between PHP serialize() data and JSON: turn strings like a:2:{…} into readable JSON, build serialized strings from JSON, and decode PHP session data.

使用说明与常见问题How-to & FAQ

「PHP 序列化/反序列化」是什么?What is the PHP Serialize / Unserialize tool?

PHP serialize() 数据与 JSON 互转:把 a:2:{…} 这样的序列化字符串还原成可读的 JSON,或把 JSON 生成 PHP 序列化字符串;也能解析 PHP Session 文件内容。Convert between PHP serialize() data and JSON: turn strings like a:2:{…} into readable JSON, build serialized strings from JSON, and decode PHP session data.

如何使用「PHP 序列化/反序列化」?How do I use the PHP Serialize / Unserialize?

选择方向:「反序列化」时粘贴 serialize() 的结果或 Session 文件内容,得到格式化的 JSON;「序列化」时输入 JSON,得到可以直接给 unserialize() 使用的字符串。字符串长度按 UTF-8 字节计算,与 PHP 一致。Pick a direction: for Unserialize paste serialize() output or session file content to get formatted JSON; for Serialize enter JSON to get a string ready for unserialize(). String lengths are counted in UTF-8 bytes, exactly like PHP.

为什么 s:6:"张三" 的长度是 6?Why is the length of s:6:"张三" 6?

PHP 序列化记录的是字符串的字节数而不是字符数,UTF-8 下一个汉字占 3 个字节,所以「张三」是 6。手动修改序列化字符串后长度对不上,unserialize() 就会失败。PHP records the byte length, not the character count; in UTF-8 each Chinese character takes 3 bytes, so 张三 is 6. If you edit a serialized string by hand and the length no longer matches, unserialize() fails.

对象和私有属性怎么显示?How are objects and private properties shown?

对象会转成带 "__class" 字段的 JSON 对象;protected/private 属性名前的 \0*\0 或 \0类名\0 前缀会被去掉。引用(r:/R:)显示为 {"__ref": 序号}。Objects become JSON objects with a "__class" field; the \0*\0 or \0Class\0 prefixes on protected/private property names are removed. References (r:/R:) are shown as {"__ref": index}.

「PHP 序列化/反序列化」免费吗?数据会上传吗?Is the PHP Serialize / Unserialize free? Is my data uploaded?

「PHP 序列化/反序列化」完全免费,无需注册或安装,手机和电脑都能用;所有处理都在你的浏览器本地完成,输入的内容和文件不会上传到服务器。The PHP Serialize / Unserialize is completely free with no sign-up or install and works on phones and desktops; everything runs locally in your browser and nothing you enter is uploaded.

相关工具Related tools

🐘 JSON 转 PHP 数组JSON to PHP Array🧾 JSON 格式化校验JSON Formatter & Validator🗄️ SQL 格式化/压缩SQL Formatter & Minifier🗃️ SQL 建表语句转 Java 实体类SQL (CREATE TABLE) to Java Entity💠 JSON 转 C# 实体类JSON to C# Class🗄️ JSON 转 SQLJSON to SQL Converter🗄️ SQL 转 JSON(INSERT 语句转 JSON)SQL to JSON Converter🗃️ CSV 转 SQL(INSERT 语句)CSV to SQL Converter🔐 Base64 编码解码Base64 Encode / Decode

← 全部工具All tools