Prepare Interview

Mock Exams

Make Homepage

Bookmark this page

Subscribe Email Address

Question: What is a constructor?
Answer: A constructor is a special method in a class that is automatically called when an object is created. It is used for initializing object properties.

Example:

class MyClass {
 public function __construct() {
 echo 'Constructor called';
 } 
}
Is it helpful? Yes No

Most helpful rated by users:

©2026 WithoutBook