Which is faster? Constants, Variables or Variable Arrays

Constants defined using define() are fairly slow in PHP. People actually wrote extensions (like hidef) to improve the performance.

But unless you have loads of constants this shouldn’t make much of a difference.

As of PHP 5.3 you can also use compile-time constants using const NAME = VALUE;. Those are much faster.

Leave a Comment