There is a difference between !isset
and empty
in PHP so while your code is looking at isset
vs !isset
but your description is saying empty
or not empty
.
Your field 'exp-date' can exist but have no value in it meaning it is empty.
Your second statement could be changed to check if the field isset
and empty
if (isset($fields['exp-date']) && (empty($fields['exp-date'])) {
echo (new DateTime('+1 month'))->format('d.m.Y');
$timeset = '';
}
You might find this explanation useful , particularly the table that shows the different states, https://www.virendrachandak.com/techtalk/php-isset-vs-empty-vs-is_null/