Answer the question
In order to leave comments, you need to log in
How will the entry from JS “value = value || 0"?
In js, there is such a nice variable assignment,
which means that if value exists, we take the value from value, otherwise we set it to 0.
Is there such a short notation in php without any isset / empty?
value = value || 0
Answer the question
In order to leave comments, you need to log in
if value exists, take value from value, otherwise set to 0.
$value = $value ?? 0
value = value || 0
$value1 = $value2 ?? 0;
would be equivalent
if (isset($value2)) {
$value1 = $value2;
} else {
$value1 = 0;
}
if ($test) {
...
] else {
...
}
$test == true ? ... : ...;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question