Last updated: August 27, 2026.
A PHP constant is a named value that cannot be reassigned while the script runs. Constant names are case-sensitive and conventionally uppercase.
<?php
declare(strict_types=1);
const ITEMS_PER_PAGE = 25;
const SUPPORTED_FORMATS = ['csv', 'json'];
define('APPLICATION_NAME', 'WebCheatSheet');
echo APPLICATION_NAME;<?php
final class ExportFormat
{
public const CSV = 'csv';
public const JSON = 'json';
}
echo ExportFormat::CSV;Use protected configuration for secrets rather than source-code constants. See the PHP constants reference.