Home >Backend Development >PHP Tutorial >Han Shunping's latest PHP object-oriented programming video tutorial courseware source code sharing
"Han Shunping's 2016 Latest PHP Object-Oriented Programming Video Tutorial" explains an important programming idea, which is object-oriented thinking. Learning this kind of thinking will be of great help to future programming.
PHP Object-Oriented Programming Video Course Introduction
Object-oriented programming has become the mainstream of PHP programming. Object-oriented programming makes programs more powerful and flexible, and is more conducive to project development and maintenance. This chapter is the top priority of PHP core programming. It requires students to deeply understand the nature of object-oriented and be able to use OOP programming ideas to write programs and projects.
Video course content: basic concepts, properties, class constants, automatically loaded classes, constructors and destructors, access control (visibility), object inheritance, range resolution operator (::), Static ( Static) keywords, abstract classes, object interfaces, Traits, overloading, traversing objects, magic methods, Final keywords, object copying, object comparison, type constraints, objects and references and object serialization
Course broadcast address: http://www.php.cn/course/452.html
The teacher lectures Style:
The teacher’s lectures are vivid, witty, witty and touching. A vivid metaphor is like the finishing touch, opening the door to wisdom for students; an appropriate humor brings a knowing smile to students, like drinking a glass of mellow wine, giving people aftertaste and nostalgia; a philosopher's aphorisms, cultural references Proverbs are interspersed from time to time in the narration, giving people thinking and warning.
The more difficult point in this video is the object-oriented magic method:
__autoload($classname); The difference between this magic method and other magic methods is that it is not in The ones used in the class, others are used inside the class. As long as a class is used in the page, the class name will be automatically passed to the parameters of this function. Use it during development to automatically load classes.
__sleep(): It is a method automatically called when object serialization is also called serialization, because serialize($object) is used when objects are serialized. If this magic method is not added to the class, it will automatically Serialize all the attributes in the class. If you only want some attributes to be serialized, you need to use this method. This method returns an array composed of the attributes of the class. Which attribute of the sequence is placed into the array. Function: Partially serialize objects.
function __sleep(){return array('name','age');} Serializes the two attributes of name and age. Which attribute is serialized returns an array containing the attribute in the __sleep method. .
$str = serialize($object)//Serialize the object into a binary string.
$newobject = unserialize($str);//Convert the binary string into a new object. This new object has the properties and methods of the original object.
__wakeup(): A method that is automatically called during deserialization, because a new object will be born when the object is deserialized, and every time a new object is born, this method is generally called. Object initialization (of course not necessary, it depends on the situation), so the function of this magic method is to initialize the newly born object.
__clone(): A method automatically called when cloning an object. $this in this method refers to the object that has just been cloned. This magic method is also used to initialize the newly cloned object. of. $that refers to the original object but it doesn't work.
__call($fnName,args): Automatically called when the object calls a method that does not exist in the class externally, to handle some error calls of non-existent methods. This method accepts two parameters, the first parameter is To access a method name that does not exist, the second parameter is the parameter array of the method that does not exist.
__toString(): Automatically called when directly outputting an object reference, because the object cannot be used directly in the class, it is the fastest way to quickly obtain the string representation of the object.
Here we also recommend downloading the source code resources: http://www.php.cn/xiazai/learn/2121
The resources are shared with you. Video courseware and source code
The above is the detailed content of Han Shunping's latest PHP object-oriented programming video tutorial courseware source code sharing. For more information, please follow other related articles on the PHP Chinese website!