.. _constants-constrecommended: .. _use-const: Use const +++++++++ The const keyword may be used to define constant, just like the `define() `_ function. When defining a constant, it is recommended to use 'const' when the features of the constant are not dynamical (name or value are known at compile time). This way, constant will be defined at compile time, and not at execution time. `define() `_ function is useful when the constant is not known at compile time, or when case sensitivity is necessary. .. code-block:: php See also `Syntax `_. Connex PHP features ------------------- + `const `_ + `define `_ Suggestions ___________ * Use const instead of define() Specs _____ +--------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Short name | Constants/ConstRecommended | +--------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Rulesets | :ref:`All `, :ref:`Analyze `, :ref:`CE `, :ref:`CI-checks `, :ref:`Coding conventions `, :ref:`Top10 ` | +--------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Exakat since | 0.8.4 | +--------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | PHP Version | All | +--------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Severity | Minor | +--------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Time To Fix | Slow (1 hour) | +--------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Precision | Very high | +--------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Examples | :ref:`case-phpmyadmin-constants-constrecommended`, :ref:`case-piwigo-constants-constrecommended` | +--------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Available in | `Entreprise Edition `_, `Community Edition `_, `Exakat Cloud `_ | +--------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+