PHP TutorialLesson 13Free preview
PHP Constants
This lesson is part of PHP · All levels
Summary
A constant is a fixed value that does not change during the program's run, created by the function define() or the keyword const within the class. Unlike a variable, a constant is not written with a dollar sign. The constant is particularly suitable for configuration values such as application names, API keys, or maximum limits.
Key points
- A constant is created by define('NAMA', value) or const within a class
- The value of a constant cannot be changed after it is defined
- The name of the constant is not preceded by the dollar sign when read
- The constant is global in nature so it can be accessed from anywhere in the script.
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.