php使用json代替serialize,有需要的朋友可参考一下.
需要注意的是 json_decode时返回的是object,需要json_decode("字符串",ture);后来发现也不是那么完美..
json_encode会对中文进行编码.如果含有大量的中文,那长度超过了serialize.这让人很蛋疼,网上给出的办法是对内容进行urlencode,json_enocde后再urldecode
实例代码如下:
<?php function jsonencode($code) { //新json_encode $code = json_encode(urlencodearray($code)); //对数组处理 return urldecode($code); } function urlencodearray($data) { //urlencode数组 if (is_array($data)) { foreach ($data as $key => $val) { $data[$key] = urlencodearray($val); } return $data; } else { return urlencode($data); } } ?>
教程地址:
欢迎转载!但请带上文章地址^^
Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article
How to fix KB5055523 fails to install in Windows 11?
3 weeks agoByDDD
How to fix KB5055518 fails to install in Windows 10?
3 weeks agoByDDD
Roblox: Dead Rails - How To Tame Wolves
4 weeks agoByDDD
Strength Levels for Every Enemy & Monster in R.E.P.O.
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Roblox: Grow A Garden - Complete Mutation Guide
2 weeks agoByDDD

Hot Tools

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

Atom editor mac version download
The most popular open source editor

Dreamweaver Mac version
Visual web development tools

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

SublimeText3 Mac version
God-level code editing software (SublimeText3)
