Which is faster? Constants, Variables or Variable Arrays in PHP?

PHPServer Side ProgrammingProgramming

Constants in PHP are defined using the 'define' function. They are fairly slow in PHP.

There are instances where extensions (such as hidef) were written to improve the performance of the code.

This comes into picture when there are thousands of constants.

Beginning from PHP version 5.3, compile-time constants with the help of const NAME = VALUE; can also be used. They are relatively quicker.

Published on 06-Apr-2020 08:48:07