PHP unserialize()

📔 : PHP 🔗

unserialize() function , serialized data को un-serialize करके उसे PHP Value में convert करता है। या कह सकते हैं stored representation data को PHP Value में convert करता है।


यह function , serialize() function के just apposite काम करता है।

PHP unserialize Syntax

unserialize ( string $data , array $options = [] );
Parameters
  1. string $data | required : यह serialized string data है जिसे हम un-serialize करना चाहते हैं।

  2. array $options | optional : यह optional में आप Associative Array pass कर सकते है , allowed_classes => true / false pass किया जाता है। By Default true ही होता है जिसका मतलब classes allowed हैं। और false का मतलब कोई भी class allowed नहीं है।


File : php_unserialize.php

Copy Fullscreen Close Fullscreen
<?php 
  $var = ['name' => 'rahul Kumar', 'age' => 24];
  $data = serialize($var);
  echo $data ."br>";
  /*now un-serialized it*/
  print_r( unserialize($data) );
?>
Output
a:2:{s:4:"name";s:11:"rahul Kumar";s:3:"age";i:24;}
Array
(
    [name] => rahul Kumar
    [age] => 24
)

Related Topics :

Rahul Kumar

Rahul Kumar

Hi ! My name is Rahul Kumar Rajput. I'm a back end web developer and founder of learnhindituts.com. I live in Uttar Pradesh (UP), India and I love to talk about programming as well as writing technical tutorials and tips that can help to others.

Get connected with me. :) LinkedIn Twitter Instagram Facebook