For Business
Login
Home
Assessments
Mytat Certificates
Community
Courses
Premium Courses
jobs
Practice
Upskilling
Projects
Help
Run »
name = $name; } public function speak() { echo "{$this->name} speaks"; } } // Child class inheriting from Animal class Dog extends Animal { public function wagTail() { echo "{$this->name} wags tail"; } } // Creating instances $animal = new Animal("Generic Animal"); $dog = new Dog("Buddy"); // Calling methods $animal->speak(); // Output: Generic Animal speaks $dog->speak(); // Output: Buddy speaks $dog->wagTail(); // Output: Buddy wags tail ?>