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

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

Jun 13, 2016 pm 12:03 PM
php ping serialize unserialize about function and Serve use

今天,在做一个关于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 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

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Article Tags

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian Dec 24, 2024 pm 04:42 PM

PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian

CakePHP Project Configuration CakePHP Project Configuration Sep 10, 2024 pm 05:25 PM

CakePHP Project Configuration

CakePHP Date and Time CakePHP Date and Time Sep 10, 2024 pm 05:27 PM

CakePHP Date and Time

CakePHP File upload CakePHP File upload Sep 10, 2024 pm 05:27 PM

CakePHP File upload

CakePHP Routing CakePHP Routing Sep 10, 2024 pm 05:25 PM

CakePHP Routing

Discuss CakePHP Discuss CakePHP Sep 10, 2024 pm 05:28 PM

Discuss CakePHP

How To Set Up Visual Studio Code (VS Code) for PHP Development How To Set Up Visual Studio Code (VS Code) for PHP Development Dec 20, 2024 am 11:31 AM

How To Set Up Visual Studio Code (VS Code) for PHP Development

CakePHP Quick Guide CakePHP Quick Guide Sep 10, 2024 pm 05:27 PM

CakePHP Quick Guide

See all articles