PHP Object-Oriented Programming: Method for developing large PHP projects (4) Author: Luis Argerich Translator: limodou advanced OOP Technology of PHP after reading the basic OOP concepts, I can show you more advanced technology: serialization PHP does not support permanent objects, in OOP, permanent objects are objects that can maintain state and function in the reference of multiple applications, which means they can be saved to a file or database, you can also load objects later. This is the so-called serialization mechanism. PHP has a serialization method, which can be called through an object. The serialization method can return the string representation of an object. However, serialization only saves the member data of the object without the package method. In PHP4, if you serialize an object to the string $ s, release the object, and deserialize the object to $ obj, you can continue to use the object method! I do not recommend that you do this because (a) the document does not guarantee that this behavior can still be used in future versions. (B) This may lead to a misunderstanding when you save a serialized version to the disk and exit the script. When you run this script in the future, you cannot expect that when deserializing an object, the object method will also be there, because the string representation does not include the method at all. All in all, PHP serialization is very useful for saving object member variables. (You can also serialize related arrays and arrays to a file ). Example :-------------------------------------------------------------------------------- -------------------------------------------------------------------------------- You restored the member data, but did not include methods (as described in the document ). As a result, you can only use $ obj2-> x to access member variables (you have no other way !) So do not try it at home. There are some ways to solve this problem. I keep it because they are too bad for this concise article. I would be very pleased to welcome the full serialization feature in subsequent PHP versions.