POO en PHP (8) - L'héritage

6 Nov 2019 · 17 min
16:56

The video is a French tutorial on object‑oriented programming in PHP, focusing on inheritance. The instructor starts from a previously built Counter class that tracks page visits via a text file. He demonstrates how to create a subclass Audience that extends Counter using the `extends` keyword, showing that the subclass initially inherits all behavior. He adds a new public method `enregistrer` to log the counter value with a timestamp to a separate file, illustrating file handling (`fopen`, `fputs`, `fclose`) and string concatenation. The lesson then explores visibility modifiers: public attributes are accessible everywhere, private attributes are limited to the defining class, and protected attributes are accessible to subclasses, recommending protected for inherited properties. The instructor shows how to declare a private attribute `ID` in the subclass and initialize it in a constructor, explaining that redefining the constructor overwrites the parent’s, so a static call to the parent constructor (`parent::construct()` or `Counter::construct()`) is required to retain parent initialization. He explains method overriding (surcharge) and the need to call the parent method when extending functionality. The tutorial covers class and method restrictions: `final` prevents inheritance or overriding, while `abstract` forces subclasses to implement abstract methods and prevents direct instantiation. He provides examples of errors when violating these rules and demonstrates correct usage. The session concludes with a recap of inheritance principles, best practices for visibility, overriding, and the use of final/abstract modifiers.

Chapters

More from Yamossoun

8:56
youtube.com

Compteur synchrone - Logique séquentielle

2w ago
11:58
youtube.com

Compteur asynchrone et diviseur de fréquence - Logique séquentielle

3w ago
11:37
youtube.com

Les registres (parallèle et à décalage) - Logique séquentielle

1mo ago
6:14
youtube.com

Bascule T (Toggle) - Logique séquentielle

1mo ago
12:05
youtube.com

Bascule JK - Logique séquentielle

1mo ago
9:17
youtube.com

Bascule D flip-flop active sur front montant - Logique séquentielle

1mo ago
10:08
youtube.com

Bascule D Latch - Logique séquentielle

1mo ago
8:13
youtube.com

Bascule RS - Logique séquentielle

1mo ago
5:04
youtube.com

Logique séquentielle - Introduction

2mo ago
1:15
youtube.com

Le codeur - Logique combinatoire #codeur #logique #circuit #booleanlogic

2mo ago
1:56
youtube.com

Algorithme de calcule de la racine carrée par dichotomie #dichotomy #squareroot #algorithm

3mo ago
See all content