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


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.

Updated on: 06-Apr-2020

162 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements