Comparing between serialize() and var_export() (1)
Date 2008-11-11 18:28:10 | Category: PHP
|
We always use 'serialize()' as a built-in function to serialize arrays/objects.
But, the format made by serialize() is hard to use for multibyte environments. This procedure:
serialize() -> encoding translation -> unserialize()
causes an error.
You may say ... "As I don't translate any text, this discussion sounds non sense"
No.
MySQL >= 4.1 stores any text as UTF-8. This means that your serialized text can be translated automatically by MySQL
(your_encoding) -> UTF-8 -> (your_encoding)
This might be a critical trouble for XOOPS session.
The I'm trying the other serialization by 'var_export()'.
var_export() outputs text like:
array(
'index' => 'value' ,
)
This format is strong for automatical/manual encoding translations. We can unserialize the data by eval().
I will discuss merits and demerits of using var_export(), tomorrow.
|
|