What is the difference between instantiating an object in the constructor vs. in a method in PHP?

When instantiating an object in the constructor, the object is created automatically when an instance of the class is created. This can be useful when the object is required for the class to function properly. On the other hand, instantiating an object in a method allows for more flexibility as the object can be created only when needed during the execution of the method.

// Instantiating an object in the constructor
class MyClass {
    private $obj;

    public function __construct() {
        $this->obj = new SomeClass();
    }
}

// Instantiating an object in a method
class MyClass {
    public function someMethod() {
        $obj = new SomeClass();
        // do something with $obj
    }
}