Skip to content
AgileLogics
3 min read

Constants

Prerequisites: String interpolation & heredoc

define() or const creates a value that can never be reassigned:

define('MAX_USERS', 100);
const APP_NAME = 'My App'; // preferred inside classes and at file scope

echo MAX_USERS; // no $ sigil — constants aren't variables

Common mistakes

  • Writing $MAX_USERS — constants have no $ prefix, unlike variables.