For Business
Login
Home
Assessments
Mytat Certificates
Community
Courses
Premium Courses
jobs
Practice
Upskilling
Projects
Help
Run »
name = $name; } public function sound() { echo "Animal sound"; } } // Define a subclass that inherits from Animal class Dog extends Animal { public function sound() { echo "Bark"; } } // Create objects of both classes $animal = new Animal("Animal"); $dog = new Dog("Dog"); // Call the sound method $animal->sound(); // Output: Animal sound $dog->sound(); // Output: Bark ?>