PHP Program to object

In PHP, an object is an instance of a class. A class is a blueprint or template for creating objects that define properties and methods.

To create an object in PHP, you first need to define a class. Here's an example :
Program :
<?php
class Person {
    public $name;
    public $age;

    public function __construct($name, $age) {
        $this->name = $name;
        $this->age = $age;
    }

    public function getInfo() {
        return "Name: " . $this->name . ", Age: " . $this->age;
    }
}

$person = new Person("John", 30);
echo $person->getInfo();
?>
Output :
Name: John, Age: 30
In the above example, we define a `Person` class with two public properties `name` and `age`, a constructor that sets the values of those properties, and a public method `getInfo()` that returns a formatted string with the name and age of the person.

To create an object of this class, we use the `new` keyword followed by the name of the class and any arguments required by the constructor. We then access the object's properties and methods using the arrow operator `->`.

Objects in PHP can also have private and protected properties and methods, which can only be accessed within the class or its subclasses. Additionally, PHP supports inheritance, which allows you to create a new class based on an existing one and extend its properties and methods.