How many maximum constants can be defined in PHP?

My site contains about 100+ constants, and this can reach 200.

I use define () to define a constant.

Will it affect performance? How many maximum constants can be defined in PHP?

+3
source share
3 answers

PHP uses hundreds of constants, so there is no problem, you can use as much as you want.

Just put this and see how many constants php uses:

$consts = get_defined_constants();
print_r($consts);

The result for me on a page containing only these lines showed a total of

990

constants used with default settings and extensions loaded

+7
source

. , , .

+5

Basically, you can have as much as memory allows. Implementing Hashtable in PHP ensures that they are accessible efficiently. There are limitations related to the fact that counters are 32-bit or 64-bit integers, but you will not have enough memory long before this becomes a problem :)

+3
source

Source: https://habr.com/ru/post/1748716/


All Articles