Set a flexible php variable

If you want php set a default variable value, but only if you yourself (in a particular case) set (before) another value of that variable, you can use a code like this:

$your_variable = $your_variable ?? $a_default_value;

That means: if you doesn’t define another value (with a code like $your_variable = "some_particular_value" ), the value of $your_variable will be $a_default_value.

Otherwise it will be "some_particular_value" .

Lascia un commento

Il tuo indirizzo email non sarĂ  pubblicato. I campi obbligatori sono contrassegnati *