Apr 27
Digg
Stumbleupon
Technorati
Delicious

Symfony and serialization

Interesting problem with data unserialization in symfony. So if you have stored serialized value in database and want to unserialize it (lets say it’s $obj->getText() value), you need to make sure you use special chars decode like here:

$value = htmlspecialchars_decode($obj->getText());
$data = unserialize($value);

Without actual htmlspecialchars_decode command PHP compiler will report about offset error.


Author: symfonian

2 Comments

Massimiliano Arione
April 27, 2011

Are you doing this in a template?
If so, it’s not really a good idea.

symfonian
April 28, 2011

Ah yes good comment, it affect only code which added to template. But I believe there are exception cases when this may need to be added in template so good to know about such issue 🙂

Comments RSS TrackBack Identifier URI

Leave a comment