How do you use constants in php?

1 answer

Answer

1212954

2026-04-09 06:40

+ Follow

Constants are simple pieces of data which cannot be changed during PHP script execution. It is useful for storing data which should remain unchanged, like a maximum or minimum value of a variable, etc.

Before first use, constant should be defined: ...

define("MY_MAX_VALUE", 505);

... After this, you can use it:

...

if ($my_variable < MY_MAX_VALUE)

{

... (some code here)

}

...

ReportLike(0ShareFavorite

Copyright © 2026 eLLeNow.com All Rights Reserved.