The brackets and the quotes are useless in this case.
if (empty($last_db_error)) {
echo "OK";
} else {
echo "Error activating subscription.";
echo $last_db_error;
}
Will do the job perfectly.
BTW, even if you do can put $vars
insides quotes in PHP, this is not recommended because :
- It works for double quotes only, single quotes will display the var name, which leads to error.
- It slows down the string parsing.
It's much more appropriate to concatenate variables using the dot operator :
if (empty($last_db_error)) {
echo "OK";
} else {
echo "Error activating subscription.\n".
$last_db_error;
}
And as soon as you have a lot of text to deal with, I urge you to use the PHP alternative syntax. E.G :
<?php if (empty($last_db_error)): ?>
OK
<?php else : ?>
Error activating subscription.
<?php echo $last_db_error; ?>
<?php endif; ?>