Home > php教程 > PHP源码 > php中serialize序列化缺陷

php中serialize序列化缺陷

PHP中文网
Release: 2016-05-25 17:11:01
Original
1373 people have browsed it

php代码

//序列化一个数组:
serialize(array("asdoasod\'asdasd", "asdaspdaso\\\\\\pdopasopd"));
//返回结果:
a:2:{i:0;s:16:"asdoasod\'asdasd";i:1;s:22:"asdaspdaso\\\pdopasopd";}

//我们一般存进数据库,带\号直接存进数据库会有一个问题,会出现自动去除'\'
//假如去除了'\'
//s:16:  这个16代表长度
//再从数据库中取出来数据,s:16的长度将会变短,这个时候:

unserialize(); //就会出现问题!
Copy after login

php代码

//序列化一个数组:
serialize(array("asdoasod\'asdasd", "asdaspdaso\\\\\\pdopasopd"));
//返回结果:
a:2:{i:0;s:16:"asdoasod\'asdasd";i:1;s:22:"asdaspdaso\\\pdopasopd";}
 
//我们一般存进数据库,带\号直接存进数据库会有一个问题,会出现自动去除'\'
//假如去除了'\'
//s:16:  这个16代表长度
//再从数据库中取出来数据,s:16的长度将会变短,这个时候:
 
unserialize(); //就会出现问题!
Copy after login
Related labels:
source:php.cn
Statement of this Website
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
Latest Articles by Author
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template