Monday, November 23
Trending
- AI-Powered Cyberattacks in 2026: How Hackers Use AI Agents
- US Outages Explained: What Happened to Microsoft, FAA and Banks
- Microsoft 365 Outage: Outlook, Teams and Copilot Down. What We Know
- Diwali Online Shopping Scams 2026: 10 Ways to Stay Safe
- 10 Best DDoS Protection Services for 2027
- 12 Best Web Application Firewalls (WAF) for 2027
- Best Ethical Hacking Tools in 2027: Free & Paid Picks
- Software supply chain attacks 2026: Timeline and developer checklist
Constants are PHP containers that remain constant and never change. Constants are used for data that is unchanged at multiple places within a program. Variables are temporary storage while Constants are permanent. Use Constants for values that remain fixed and referenced multiple times.
Rules for defining constant
PHP constants can be defined in 2 ways:
- Using define() function
- Using const keyword
Using define() function
define(name, value, case-insensitive)
name: Name of the constant
value: Value of the constant
case-insensitive: Whether a constant is case-insensitive, The default value is false.
Using const keyword
The const keyword defines constants at compile time. It is a language construct, not a function.
<?php
const MESSAGE = "Welcome to PHP";
echo MESSAGE;
?>



