|
所在平台: Udemy |
课程主页: https://www.udemy.com/course/oop-object-oriented-programming-in-php-7/
课程评论:没有评论
本课程“PHP 7 中的 OOP 面向对象编程”全面深入地探讨了面向对象编程(OOP)的核心概念和 PHP 7 中的实现。 课程从 OOP 的基本介绍开始,涵盖了 OOP 的定义、必要性以及它出现的历史背景,同时对比了过程式语言。随后,深入讲解了 OOP 的优势,并逐步引导学习者在编程中融入 OOP 思想。 课程的第二部分聚焦于 OOP 的基础知识,通过现实生活中的例子帮助理解对象、类、属性和方法的映射关系。详细讲解了如何在 PHP 中创建类和对象,添加和使用属性与方法,以及方法的参数和返回值。 接下来的章节深入探讨了 OOP 的关键特性: * **可见性(Visibility)**:讲解了 public、private 和 protected 三种可见性级别及其在类中定义属性和方法时的作用。 * **常量(Constants)**:介绍了类中常量的概念。 * **封装(Encapsulation)**:解释了封装的必要性、实现方式及其带来的好处。 * **继承(Inheritance)**:通过现实生活中的例子解释了继承,以及如何在 PHP 中实现继承,并区分了 ISA 和 HASA 关系的应用场景。 * **方法重写(Method Overriding)**:解决了子类需要重写父类方法以实现特定功能的问题,并讲解了如何在重写的同时保留父类方法的功能。 * **Final 关键字**:介绍了如何使用 final 关键字阻止继承和方法重写。 * **抽象概念(Abstract Concepts)**:详细讲解了抽象类的意义、必要性,以及抽象方法的概念和在 PHP 中的创建方式,并总结了抽象类和方法的核心要点。 * **接口(Interfaces)**:解决了不同类层级之间需要共享行为的问题,并通过接口提供解决方案。 * **构造函数与析构函数(Constructors and Destructors)**:讲解了对象诞生和消亡时的处理机制,并通过魔术方法 `__construct()` 和 `__destruct()` 演示了如何定义和使用它们。 * **静态成员(Static Members)**:介绍了如何使用 `static` 关键字创建类的共享属性和方法,无需实例化对象。 * **魔术方法(Magic Methods)**:深入探讨了 PHP 中15个魔术方法的具体用法。 * **错误与异常处理(Errors and Exceptions)**:该部分是课程的重头戏,详细介绍了 PHP 中的各种错误类型、发生原因、错误报告机制、处理错误(如使用错误处理程序和记录错误日志)的四种方法。同时,讲解了如何使用异常(Exceptions)来处理代码中的风险行为,包括 `try`、`throw`、`catch` 的使用,异常类的细节,自定义异常,多 `catch` 块,异常重抛,未捕获异常的处理,以及异常处理程序。最后,重点介绍了 PHP 7 中错误与异常处理的更新。 * **类自动加载(Class Autoloading)**:讲解了如何在不使用 `include` 和 `require` 的情况下自动加载类,以及 `autoloader` 函数的应用。重点介绍了命名空间(Namespaces)的概念,以及如何使用 PSR-0 和 PSR-4 标准来自动加载命名空间类。 * **对象序列化(Object Serialization)**:介绍了对象序列化的必要性、时机和方法,以及如何通过 `__sleep()` 和 `__wakeup()` 魔术方法在序列化和反序列化前后执行特定任务。 * **对象克隆(Object Cloning)**:深入探讨了浅拷贝和深拷贝两种克隆方式,介绍了 `__clone()` 魔术方法,递归克隆,双重链接问题,以及如何使用序列化实现深拷贝克隆。 * **类型提示(Type Hinting)**:讲解了如何使用标量和非标量数据类型进行类型提示,以及 PHP 7 中引入的严格标量类型和 `TypeError` 异常。 * **对象比较(Object Comparison)**:介绍了使用比较运算符 (==) 和身份运算符 (===) 两种方式来比较对象。 * **对象重载(Object Overloading)**:详细讲解了如何通过 `__get()`, `__set()`, `__isset()`, `__unset()` 实现属性重载,以及通过 `__call()` 和 `__callStatic()` 实现方法重载。 * **Traits**:解决了多重继承中的“致命钻石问题”,对比了单继承的局限性,介绍了 Traits 如何实现多重继承,以及在不同场景下(父类与 Traits,Traits 与当前类)方法冲突时的优先级顺序。还包括了使用多个 Traits、组合 Traits,以及 Traits 中抽象成员和静态成员的应用。 * **Late Static Binding**:在讲解了绑定(Binding)、早期绑定(Early Binding)和晚期绑定(Late Binding)等基本概念后,揭示了 `self` 关键字在早期绑定中存在的问题,并提供了 Late Static Binding 作为解决方案。 * **对象迭代(Object Iteration)**:介绍了遍历(Traverse)、迭代(Iterate)等基本概念,以及如何使用 `Iterator` 接口和 `IteratorAggregate` 接口来实现对象的迭代。 本课程为学习者提供了一个扎实的 PHP OOP 基础,并涵盖了现代 PHP 开发中的重要概念和实践。
1st section of the course starts with an introduction to object oriented programming. What is OOP? and why we need it ? and what was before OOP?. A little detail about procedural language.We will also learn how to add OOPness in our programming. Then the advantages of object oriented programming. In 2nd section we will discuss the basics of OOP with real life example and then how to map it in objects, classes, properties and method. Then how to create objects and classes in php? How to add properties and methods? How to use them? And at the end of this section we will learn about parameters and return values of a method. 3rd section describes the visibility and its three levels. Then why we need to define public, private or protected visibility of properties and methods in a class. 4th section describes the concept of constants in classes. 5th section describes about data encapsulation. Why we need it? And how to implement it and then the benefits of encapsulation. In 6th section we will discuss about inheritance with real life example. Then how to translate it in classes, properties and methods in php code. What is ISA and HASA relationship and where to use ISA and where to use HASA in classes and objects. 7th section describes the problem when a child class needs its own version of parent class method then how overriding of method solves this problem. Then how you can preserve parent class method's functionality while overriding. 8th section describes how you can block inheritance and method overriding using final keyword. 9th section describes what is the meaning of abstract in real world, then what is the meaning of abstract classes, why we need i? What are the abstract methods and why we need it? Then we will also discuss how to create abstract classes and methods in php. At the end what are the key points for abstract classes and methods. In 10th section we will discuss what happens when two classes from completely different class hierarchies need some similar behaviour and how interface solve this problem. In 11th section we will discuss what happens when an object is born and when it dies. How we can handle things in both situations using constructor and destructor. How to define and use constructor and destructor using magic methods __construct() and __destruct(). 12th section describes a situation where we need only one copy of properties and methods for all objects of a class. Static keyword can solve this problem. So we will see how we can create and use static properties and methods without creating an object of a class. In 13th section describes that there are 15 magic methods in php. So we will discuss these magic methods one by one in detail. 14th section is the biggest one in this course. In this we will discuss about errors and exceptions. What supposed to be an error in php? How they happen? What are the different types of errors?.how you can trigger errors by yourself? And what are the logical error? Then we will see how we can report errors when they happen and how you can change error reporting settings in php.ini. We will also learn the 4 ways to deal with errors. Then how to use an error handler and at last how you can log error messages. After errors we will discuss about what may be the risky behavior of your code and how we can use exceptions to handle that risky behaviour. We will see how we can try some risky behaviour then how we can throw an exception if anything wrong happens and how we can catch that exception. Then the detail discussion on exception class in php and the stack trace for the exception. Then how you can make your own custom exceptions by extending php's built in exception class. Why we need to use try with multiple catches and how to re-throw an exception. What happens when there is an uncaught exception in your code.what is an exception handler. Then at the end of this section we will discuss the changes in errors and exceptions in php7. 15th section describe how you can autoload classes in your code without using include and require statements. Then the use of autoloader function for this purpose. Then we will discuss to autoload namespace classes in your code using Psr-0 and Psr-4 autoloading standards but before that we will discuss what are the namespaces in php. 16th section is about object serialization. Why we need to serialize an object. Then when and how to unserialize it. We will also learn how to do task that are prior to serializing an object using __sleep() magic method.Then how to do task right away after unserializing an object using __wakeup() magic method. 17th section is about cloning of an object in which we will discuss two types of cloning that are shallow copy and deep copy. In deep copy cloning we will also discuss about __clone() magic method. Then we will see recursive cloning and then double linking problem in cloning. At the end we will discuss Deep copy cloning using serialization. 18th section is about Type hinting. In this we will see how we can use non scalar and scalar data types for type hinting. We will also discuss about strict scalar data types and TypeError exception thats been introduced in php7. In 19th section we will learn two ways of comparing objects. First one is using Comparison operator (==) and 2nd one is using Identity operator (===). 20th section is about overloading an object. we will learn How to do property overloading Using __get(), __set(), __isset() and __unset() magic methods. Then how to do method overloading Using __call(), __callStatic() magic methods. 21st section describes about traits. First we will discuss deadly diamond of death problem in multiple inheritance. Then single inheritance and its limitations. Then how traits provide multiple inheritance thing in php. Then what will be the precedence order if a parent class and a trait have same method and then what will be the precedence order if a trait and current class have the same method. We will also discuss to use multiple traits and then how to compose a trait from other traits. At the end we will discuss abstract and static trait members and trait properties. 22nd section describes late static binding. For this first we will discuss some basic concepts of binding like what is binding, early binding and late binding? Then what is the problem with early binding of self keyword and at the end its solution which is late static binding. 23rd section describes object iteration. First we will get some idea about some basic concepts like traverse, iterate and iterate using loops. Then what is object iteration and how you can iterate an object using Iterator Interface and IteratorAggregate Interface.