Home > Backend Development > PHP Tutorial > Method 4 for developing large-scale PHP projects_PHP Tutorial

Method 4 for developing large-scale PHP projects_PHP Tutorial

WBOY
Release: 2016-07-13 17:25:40
Original
851 people have browsed it

PHP's advanced OOP technology After seeing the basic OOP concepts, I can show you more advanced technologies: Serializing (Serializing) PHP does not support persistent objects. In OOP, permanent objects can be referenced in multiple applications. Objects that maintain state and functionality, which means having the ability to save the object to a file or database and to load the object later. This is the so-called serialization mechanism. PHP has a serialization method that can be called on an object, and the serialization method can return a string representation of the object. However, serialization only saves the member data of the object and not the methods. In PHP4, if you serialize the object into the string $s, then release the object, and then deserialize the object into $obj, you can continue to use the object's methods! I don't recommend doing this because (a) there is no guarantee in the documentation that this behavior will still work in future versions. (b) This may lead to a misunderstanding when you save a serialized version to disk and exit the script. When you later run this script, you cannot expect that when you deserialize an object, the object's methods will be there, because the string representation does not include methods at all. In short, serialization in PHP is very useful for saving member variables of objects. (You can also serialize related arrays and arrays into a file). example: ------------------------------------------------ ----- --------------------------------------------- --------- You restored the member data, but not the methods (according to the documentation). This results in the only way to access member variables (you have no other way!) by something like using $obj2->x, so don't try it at home. There are some ways to solve this problem, I left them out because they are too bad for the purpose of this concise article. I will happily welcome fully serialized features in subsequent versions of PHP.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/532030.htmlTechArticleAdvanced OOP Technology in PHP After seeing the basic OOP concepts, I can show you more advanced technology : Serializing (Serializing) PHP does not support permanent objects. In OOP, permanent objects can be...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template