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
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *