POO en PHP (4) - Constantes de classe

18 Aug 2019 · 6 min
6:03

In this French tutorial, the instructor explains PHP class constants, their purpose, and how to declare and use them. He starts by comparing a hard‑coded tax rate (20) with a named constant, showing that constants improve code readability. He demonstrates declaring a constant with the `const` keyword inside a `Facture` class, accessing it from outside the class using the scope resolution operator (`ClassName::CONST`), and from inside the class using both the absolute class name and the `self` keyword. The example calculates a TTC amount from a HT amount using a TVA constant of 20 %. The lesson also clarifies the difference between `self` (refers to the class) and `$this` (refers to the instance) and emphasizes best practices for using class constants to make code clearer.

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