php - Remove blank line from else statement
I've been researching if/else statements, and I've built one without any issue, on my else statement I use$tpl->set('message', '');
the '' quotes are to indicate to not show anything (which is what I want), on my template I use {message} to echo a message during the if statement, but I was wondering, as I don't want to echo anything on an else statement is leaving the quotes empty best practice?, as with it empty it keeps the {message} hidden on my template which is what I wanted, sorry if my question is rather basic, I'm still learning, thank you very much.
Edit: Just to clarify with the title, on the html output where the {message} would appear is a blank line, is it possible to remove it?
Answer
Solution:
Yes you can. You can just check if the
message
is empty or not using theempty()
. If the $message is not empty, only then show the message as below.Note: I don't know what templating you are using. So, this is the basic idea, you might need some adjustment to fit it for the template you are using.