Complete the code to define a constant named PI with value 3.14 inside the class.
<?php class Circle { const [1] = 3.14; } ?>
The constant name is PI as per convention and the problem statement.
Complete the code to access the constant PI from the Circle class.
<?php class Circle { const PI = 3.14; } echo Circle::[1]; ?>
Constants are accessed using the class name, double colon, and the constant name exactly as declared, which is PI.
Fix the error in the code to correctly access the constant MAX_SPEED inside the Car class.
<?php class Car { const MAX_SPEED = 200; public function getMaxSpeed() { return self::[1]; } } ?>
Inside the class, constants are accessed with self::CONSTANT_NAME using the exact constant name MAX_SPEED.
Fill both blanks to define a constant SPEED_LIMIT and access it inside the class method.
<?php class Bike { const [1] = 100; public function getSpeedLimit() { return self::[2]; } } ?>
The constant name must be the same in both declaration and access: SPEED_LIMIT.
Fill all three blanks to define a constant COLOR, access it inside the class, and print it outside the class.
<?php class Car { const [1] = 'red'; public function getColor() { return self::[2]; } } echo Car::[3]; ?>
The constant name is COLOR and must be used exactly as declared both inside and outside the class.