Hongmu Notes
Home Language Notes PHP serialize() function
Language Notes PHP

PHP serialize() function

PHP serialize() function

The serialize() function is used to serialize an object or array and returns a string.

After the serialize() function serializes an object, it can be easily passed to other places that need it, and its type and structure will not change.

If you want to convert a serialized string back into a PHP value, use unserialize()

PHP version requirements: PHP 4, PHP 5, PHP 7

Grammar


string serialize ( mixed $value )

Parameter description:

$value: The object or array to be serialized.

return value

Returns a string.

Example


<?php
$sites = array('Google', 'Runoob', 'Facebook');
$serialized_data = serialize($sites);
echo  $serialized_data . PHP_EOL;
?>

The output is:


a:3:{i:0;s:6:"Google";i:1;s:6:"Runoob";i:2;s:8:"Facebook";}
微信赞赏

WeChat

支付宝赞赏

Alipay

✍️ Author: Hong Mu

webmaster · Thanks for reading, stay tuned for more exciting content

Author homepage View home page →

Related articles

PHP ob function record

PHP ob function record Language Notes PHP

Usage of the following three functions ob_get_contents(); ob_end_clean(); ob_start(); You can use these functions to buffer local files and execute local script code. Use ob_start() to save the output code into the buffer, and the page will not be displayed; then use ob_get_contents to get the data in the buffer. o…
👁 141
PHP preg

PHP preg Language Notes PHP

The preg_match_all function is used to perform a global regular expression match. preg_match_all() Syntax int preg_match_all ( string $pattern , string $subject [, array &$matches [, int $flags = PREG…
👁 169
Detailed explanation of PHP ternary operator and if

Detailed explanation of PHP ternary operator and if Language Notes PHP

Ternary operator condition ? Result 1 : Result 2 Explanation: The position in front of the question mark is the condition for judgment. If the condition is met, the result is 1, and if it is not met, the result is 2. This article compares and explains the ternary operator and if...else... in detail. I hope it will be helpful to everyone. Today when I was revising my paper online, I encountered a statement that I couldn’t understand: $if_summary = $row['IF_SUMMARY']=…
👁 189
PHP cast type

PHP cast type Language Notes PHP PHP collection PHP and mysql

Get the data type 1. If you want to check the value and type of an expression, use var_dump(). 2. If you just want to get an easy-to-read type expression for debugging, use gettype(). 3. To check a certain type, do not use gettype(), but use the is_type() function. Converting Strings to Numbers When a string is evaluated as a number, the result is determined according to the following rules...
👁 232

Recommended reading

Responsive tea product display and sales website template – 1197

Responsive tea product display and sales website template – 1197 Practical Collection Yiyou template

An EyouCMS responsive website template designed for the tea exhibition and sales industry. Its classical and elegant design is ideal for showcasing tea products, brand stories, tea culture, and sales information. This template helps tea brands effectively present their products online and attract both tea enthusiasts and distributors. Template Display | Installation Instructions | Website Backend: /login.php | Username: admin | Password: admin | Related Articles: Summary of Common Installation Issues for EyouCMS...
👁 56
jQuery click Ajax to submit data

jQuery click Ajax to submit data Language Notes JavaScript

The following is a simple click event, using jQuery to send an AJAX request and submit the data to the server, and display a pop-up window when the data is returned: $(document).ready(function() { $('button').click(function() { // Define the data to be submitted var data = { name: '…
👁 166
(Adaptive Mobile Version) Injection Molding Processing Website Template – Download Website Source Code for Molded Products – 0951

(Adaptive Mobile Version) Injection Molding Processing Website Template – Download Website Source Code for Molded Products – 0951 Practical Collection pbootcms Template

A PbootCMS website template designed for injection molding manufacturing and mold-related products, compatible with both PC and WAP devices. Its professional and practical design makes it ideal for showcasing injection molding products, mold design, and customized services. This template helps injection molding enterprises demonstrate their capabilities online and expand their network of potential partners. Template Display | Installation Instructions | Website Backend: /admin.php | Username: admin | Password: admin | Extraction Password: www.4s5.cn | Related Articles: P...
👁 43
Responsive gourmet dessert and cake website template – 1198

Responsive gourmet dessert and cake website template – 1198 Practical Collection Yiyou template

This EyouCMS responsive template is ideal for the food, dessert, and cake industries. Its warm and inviting design is perfect for showcasing cakes, desserts, gourmet products, brand stories, product ranges, and franchise information. It helps baking brands attract both consumers and franchisees online. Template Display | Installation Instructions | Website Backend: /login.php | Username: admin | Password: admin | Related Articles: Summary of Common Installation Issues for EyouCMS | EyouCMS (...
👁 37
(Adaptive mobile version) Sandbox Model Creation Website Template – Download Blue Architectural Model Website Source Code: 0952

(Adaptive mobile version) Sandbox Model Creation Website Template – Download Blue Architectural Model Website Source Code: 0952 Practical Collection pbootcms Template

A PbootCMS website template for creating sand table models and blueprints, compatible with both PC and WAP devices. Featuring a professional artistic design style, it is ideal for showcasing sand table models, architectural models, and design projects. This template helps model companies display their work online and attract clients in the real estate and design industries. Template Display | Installation Instructions | Website Backend: /admin.php | Username: admin | Password: admin | Extraction Password: www.4s5.c...
👁 37