class Person { public $name; public function __construct($n) { $this->name = $n; } } $person = new Person('John'); echo $person->name; // Output: John
class Product { public $name; public $price; public $quantity; public function __construct($n, $p, $q) { $this->name = $n; $this->price = $p; $this->quantity = $q; } public function getTotal() { return $this->price * $this->quantity; } } $product = new Product('Apple', 0.5, 10); echo $product->getTotal(); // Output: 5In this example, the Product class has a constructor that takes three parameters ($n, $p, $q) and sets the values of the $name, $price, and $quantity properties to the values of the parameters. It also has a getTotal method that calculates and returns the total value of the product. Both examples belong to the core PHP package library, as they are part of PHP's object-oriented programming features.