Short video - getter, setter, toString (les méthodes magiques en PHP)

In this short French-language tutorial, the presenter explains PHP "magic" methods—functions that are invoked automatically by the engine when certain events occur. He revisits the constructor (construct) and destructor (destruct) as examples of magic methods that run without explicit calls. He then demonstrates how to design a custom class, PHPString, to work with character strings (the keyword String being reserved in PHP 7+). The class declares two properties, `str` (the string to process) and `length` (its length). A constructor is defined that receives a user‑provided string, assigns it to `str`, computes its length, and stores the result in `length`. The video sets the stage for later discussion of getters, setters, and a toString method, illustrating how magic methods simplify object lifecycle handling in PHP.










