1.2.217. Const Or Define

const and define() have the same functional use : create constants.

The analyzed code has less than 10% of one of them : for consistency reasons, it is recommended to make them all the same.

They are almost interchangeable, though not totally : define() allows the creation of case-insensitive constants, while Const won't.

<?php

// be consistent
const A1  = 1 ;
const A2  = 2 ;
const A3  = 3 ;
const A4  = 4 ;
const A5  = 5 ;
const A6  = 6 ;
const A7  = 7 ;
const A8  = 8 ;
const A9  = 9 ;
const A10 = 10;
const A11 = 11;

define('A12', 12); // Be consistent, always use the same.

?>

See also define and const.

1.2.217.1. Specs

Short name

Structures/ConstDefineFavorite

Rulesets

All, Appinfo, CE

Exakat since

0.12.1

PHP Version

All

Severity

Time To Fix

Precision

Very high

Features

constant

Available in

Entreprise Edition, Community Edition, Exakat Cloud