Классы описывают структуру данных. private скрывает данные, public дает доступ через методы. __construct() — конструктор.
class Course { private $name; private $price; public function __construct($name, $price) { $this->name = $name; $this->price = $price; } public function getPriceWithDiscount($percent) { return $this->price * (1 - $percent / 100); } public function getFullInfo() { return "Курс: " . htmlspecialchars($this->name) . ", цена: " . number_format($this->price, 0, ".", " ") . " ₽"; } } $course = new Course("Основы PHP", 5900); echo $course->getFullInfo() . "<br>"; echo "Цена со скидкой 20%: " . number_format($course->getPriceWithDiscount(20), 0, ".", " ") . " ₽";