SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Addict dr_dumb99's Avatar
    Join Date
    Sep 2004
    Location
    Pakistan
    Posts
    304
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Some Clarification

    Hi!
    I want to get knowledge about Serialised and unserialised output in very simple manner .

    Thanks in advance

  2. #2
    Theoretical Physics Student bronze trophy Jake Arkinstall's Avatar
    Join Date
    May 2006
    Location
    Lancaster University, UK
    Posts
    7,062
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Basically, serializing is a way of storing an object (including all of it's details) as a string.

    unserializing is the opposite, returning the string to an object.

    To test this out, try this:
    PHP Code:
    <?
    class hello{
        var 
    $name;
        function 
    changename($newname){
            
    $this->name $newname;
        }
        function 
    echoname(){
            echo 
    $this->name;
        }
    }
    $bar = new hello;
    $bar->changename("bob");
    $objstring serialize($bar);
    $foo unserialize($objstring);
    $foo->echoname();
    That should work, although it isn't tested. If you eho $objstring, you'll see how it's stored.
    Jake Arkinstall
    "Sometimes you don't need to reinvent the wheel;
    Sometimes its enough to make that wheel more rounded"-Molona

  3. #3
    . shoooo... silver trophy logic_earth's Avatar
    Join Date
    Oct 2005
    Location
    CA
    Posts
    9,013
    Mentioned
    8 Post(s)
    Tagged
    0 Thread(s)
    serialize is not only for objects.
    read http://php.net/serialize

    Generates a storable representation of a value
    This is useful for storing or passing PHP values around without losing their type and structure.
    To make the serialized string into a PHP value again, use unserialize().
    Logic without the fatal effects.
    All code snippets are licensed under WTFPL.



Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •