The constructor is a method named __construct() , which is automatically called by the
new keyword after creating the object. It is usually used to automatically perform various initializations.

class Person {
function __construct($name)
{
$this->name = $name;
}
function getName()
{
return $this->name;
}
private $name;
};
$judy = new Person("Judy") . "\n";
$joe = new Person("Joe") . "\n";
print $judy->getName();
print $joe->getName();