Home  >  Article  >  Backend Development  >  What characters in php will affect the parsing of unserialize()?

What characters in php will affect the parsing of unserialize()?

PHP中文网
PHP中文网Original
2016-08-18 09:16:101125browse


What characters in PHP will affect the parsing of unserialize?

Reply content:

What characters in PHP will affect the parsing of unserialize?


Correct answer upstairs
For example, under utf8 encoding

echo serialize('我'); 
//输出: s:3:"我";

under gbk encoding

echo serialize('我'); 
//输出:s:2:"我";

So you can never serialize the 3-byte long 'I' under utf8 encoding and deserialize under gbk encoding parsed out


I think it should be caused by the inconsistency between the encoding when serializing the data and the encoding when deserializing, or you can post the wrong statement for easy analysis


/

In the past two days, I I have encountered

The above is what characters in PHP will affect the parsing of unserialize()? For more related content, please pay attention to the PHP Chinese website (www.php.cn)!


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