Friday, October 24, 2025
HomeLanguagesPHP | ArrayObject serialize() Function

PHP | ArrayObject serialize() Function

The ArrayObject::serialize() function is an inbuilt function in PHP which is used to serialize the ArrayObject.

Syntax:

string ArrayObject::serialize( void )

Parameters: This function does not accept any parameters.

Return Value: This function returns the serialized representation of the ArrayObject.

Below program illustrates the ArrayObject::serialize() function in PHP:

Program:




<?php 
// PHP program to illustrate the 
// ArrayObject::serialize() function 
  
// Declare an associative array
$arr = array(
    "a" => "Welcome",
    "b" => "to"
    "c" => "neveropen"
); 
  
// Create array object 
$arrObject = new ArrayObject($arr); 
  
// Use ArrayObject::serialize() function
// to get the behavior of flags
$serialize1 = serialize($arrObject);
$serialize2 = $arrObject->serialize();
  
// Display the result
var_dump($serialize1); 
var_dump($serialize2); 
  
?> 


Output:

string(113) "C:11:"ArrayObject":89:{
    x:i:0;a:3:{
        s:1:"a";s:7:"Welcome";
        s:1:"b";s:2:"to";
        s:1:"c";s:13:"neveropen";
    }
    ;m:a:0:{}
}"
string(89) "x:i:0;a:3 {
    s:1:"a";s:7:"Welcome";
    s:1:"b";s:2:"to";
    s:1:"c";s:13:"neveropen";
};m:a:0:{}"

Reference: https://www.php.net/manual/en/arrayobject.serialize.php

RELATED ARTICLES

Most Popular

Dominic
32361 POSTS0 COMMENTS
Milvus
88 POSTS0 COMMENTS
Nango Kala
6728 POSTS0 COMMENTS
Nicole Veronica
11892 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11954 POSTS0 COMMENTS
Shaida Kate Naidoo
6852 POSTS0 COMMENTS
Ted Musemwa
7113 POSTS0 COMMENTS
Thapelo Manthata
6805 POSTS0 COMMENTS
Umr Jansen
6801 POSTS0 COMMENTS