PHP constants are used to define the values that will remain constant without changing the name of the variable. In addition, the constants are safe only because they cannot be defined and changed once.
Defining constants is done with
define() function. It is implemented with two arguments.
<?php define ('site_name', 'baransel.dev'); // We created a constant named site_name and set its value to baransel.dev ?>
The names we use for the constants are the same as the names of the variables.
When using constants, we should not put a dollar ($) sign on the beginning like in the variables. Constants are written and used directly without adding a character.
<?php define ('planet', 'world'); echo planet; ?>
The world is written on the screen.