This is a simple example for understanding serialize and unserialize object in php. we hide the object in a row using serialization and use the current status of the current object (with the given values) after non-serialization on another page.
c.php
<?php class A { public $one ; public function A($val) { $this->one=$val;
The c.php file has a class named A.
a.php
<? require_once "c.php"; $ob= new A('by Pankaj Raghuwanshi : Object Searlization.'); $ob->display(); <br><A href='b.php?s=<?=$s;?>'>B-file</a>
We serialize the conversion of this object to a string and pass this string to another page using the get method.
Note. . We can transfer this line from one page to another page using various methods, such as using a session, we can save to the database and extract another page, save to a text file.
We will exclude this object for another b.php file name
b.php
<? require_once "c.php"; $ob = unserialize($_GET[s]); $ob->display();
after unserialization, the object shows the same behavior as the a.php file and assigning the value a.php is still in the object's memory. if we refuse this object after many HTTP requests. The object will store all destination values ββin its memory.
source share