search
Homephp教程php手册非常好用的两个PHP函数 serialize()和unserialize()

非常好用的两个PHP函数 serialize()和unserialize()

Jun 13, 2016 pm 12:03 PM
phppingserializeunserializeaboutfunctionandServeuse

今天,在做一个关于PING服务的东西,由于不想把ping服务地址放进数据库中,那样不好,ping服务本来不是一个效率不高的事,再放进数据库中,不但更加降低了程序的效率,还给服务器带来不必要的损耗,所以,想办法所ping服务地址用数组的方式放进了.conf文件中,才开始的设计思路是通过生成的php代码放到.php文件中,然后再把.php文件载入进来,后来,发现操作起来不太方便,所以,决定使用serialize()函数和unserialize()函数,这两个函数的用法真是绝配,一个是进行序列化存储,另一个则是进行序列化恢复,方便极了,函数用法代码分享:

复制代码 代码如下:


$array = array();
$array['key'] = 'website';
$array['value']='www.chhua.com';
$a = serialize($array);
echo $a;
unset($array);
$a = unserialize($a);
print_r($a);
?>


没有写太具体的用法,童鞋可以自己思考,然后尝试,还是那句话,我这里说的只是一种思路和方法,具体用法,还是要自己研究。
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

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

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

Hot Tools

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

Atom editor mac version download

Atom editor mac version download

The most popular open source editor