class Person { public $name; public $age; function __construct($name, $age) { $this->name = $name; $this->age = $age; } } // Creating a new instance of the Person class $person1 = new Person("John", 25); echo "Name: " . $person1->name . "
"; echo "Age: " . $person1->age . "
";
use Illuminate\Database\Eloquent\Model; class Product extends Model { public function __construct(array $attributes = []) { parent::__construct($attributes); $this->table = 'products'; } } // Creating a new instance of the Product class $product1 = new Product(); echo "Table: " . $product1->table . "In this example, we have a Product class that extends the Illuminate\Database\Eloquent\Model class, which is a package library used for working with databases in Laravel. We override the __construct function in the Product class to set the $table property to 'products' when a new object of the Product class is created. We then print out the $table property to the screen. This code uses the Laravel package library.
";