Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Format::Unserialize
  • Is there a method to unserialize a string?
    something like : Format::factory($serialized_string,'serialized')->to_array(); or is should i just use unserialize() ?
    thank you.
  • i think there is no such function in the Format class use simply php
    unserialize()
    
  • Why would you want that? Seems pretty useless, only adds overhead and nothing usefull compared to unserialize().
  • Jelmer Schreuder wrote on Saturday 16th of July 2011:
    Why would you want that? Seems pretty useless, only adds overhead and nothing usefull compared to unserialize().

    true but then again so is the serialize method no? I am not sure what it ads over the php serialize method.
  • In that case you don't understand what the Format class is meant for. It's meant to input something and help you convert/format it to something else. Making it unserialize is nonsense because of this:
    Format::factory($serialized_string,'serialized');
    Format::factory(unserialize($serialized_string));
    

    The second example is exactly as much code as the first, and you'd never want to be able to do this in multiple ways. While this might be usefull the other way around:
    $format = Format::factory(array('example', 'something'));
    $this->response->body = $format->{'to_'.$output}();
    

    Where $output might contain 'serialized', 'json', 'xml', etc...
  • Jelmer Schreuder wrote on Saturday 16th of July 2011:
    In that case you don't understand what the Format class is meant for. It's meant to input something and help you convert/format it to something else. Making it unserialize is nonsense because of this:
    Format::factory($serialized_string,'serialized');
    Format::factory(unserialize($serialized_string));
    

    The second example is exactly as much code as the first, and you'd never want to be able to do this in multiple ways. While this might be usefull the other way around:
    $format = Format::factory(array('example', 'something'));
    $this->response->body = $format->{'to_'.$output}();
    

    Where $output might contain 'serialized', 'json', 'xml', etc...

    I see what you mean. thanks for taking the time to explain it. Although the docs are very good, it is always nice to have specific scenarios to better understand thing. ( i know that's much to ask for at this point given the amount of work you guys already do)

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion