You are writing a PHP script and you need to define a constant in a class. How would you do this?
- const CONSTANT_NAME =
- define(CONSTANT_NAME,
- static CONSTANT_NAME;
- var CONSTANT_NAME;
To define a constant in a class in PHP, you can use the const keyword followed by the constant name and its value. For example: const CONSTANT_NAME = value; Constants in a class are associated with the class itself and can be accessed using the class name without the need for object instantiation. They provide a way to store values that remain constant throughout the execution of the script. Refer to: http://php.net/manual/en/language.constants.php
Loading...
Related Quiz
- You are writing a PHP script and you need to define a static method. How would you do this?
- How can we pass a variable through navigation between pages?
- What are some common practices in PHP data filtering and validation?
- A common use case of the include statement in PHP is to include ______.
- PHP uses the global keyword to make a local variable have global scope.