Complete the code to declare a class named Car.
<?php class [1] { } ?>
The keyword class is followed by the class name, which should start with a capital letter by convention. Here, Car is the correct class name.
Complete the code to add a public property named $color to the class.
<?php class Bike { public [1]; } ?>
The property name $color matches the instruction to add a public property named $color.
Fix the error in the class declaration by completing the code.
<?php
[1] Vehicle {
}
?>The keyword class is required to declare a class in PHP. Using function or others here is incorrect.
Fill both blanks to declare a class named Person with a private property $name.
<?php [1] Person { [2] $name; } ?>
The class declaration starts with class. The property $name is declared private as requested.
Fill all three blanks to declare a class named Animal with a protected property $species and a public method speak().
<?php [1] Animal { [2] $species; [3] function speak() { echo "Hello!"; } } ?>
class.The class is declared with class. The property $species is protected to allow access in subclasses. The method speak() is public so it can be called from outside.