A constructor in a PHP class is defined using the __construct() method.

  • method
  • function
  • keyword
  • property
In PHP, a constructor in a class is defined using the __construct() method. The correct option is "method." The __construct() method is a special method that is automatically called when an object of the class is created. It is used to initialize the object's properties or perform any necessary setup tasks. For further details, refer to the PHP documentation on constructors: http://php.net/manual/en/language.oop5.decon.php
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *