Web 3
Web 3
// Constructor
public function __construct($value1, $value2) {
// Initialize properties
$this->property1 = $value1;
$this->property2 = $value2;
// Constructor
public function __construct($brand, $model, $year) {
$this->brand = $brand;
$this->model = $model;
$this->year = $year;
}
// Method to display information about the car
public function displayInfo() {
echo "Brand: {$this->brand}, Model: {$this->model}, Year: {$this->year}\n";
}
// Creating an object (instance) of the Car class
$myCar = new Car("Toyota", "Camry", 2022);
• // Constructor
• public function __construct($name, $age, $gender) {
• $this->name = $name;
• $this->age = $age;
• $this->gender = $gender;
• }
public function displayInfo()
{
echo "Name: {$this->name}, Age: {$this->age}, Gender: {$this>gender}\n";
}
$person1->displayInfo();
• class JConfig {
• //set it
• $jc->setHost("MyHost");
• //get it
• echo $jc->getHost();