This probably might be a silly question, but what I am trying to do is to make an if statement to do the following:
<?php if ($_SESSION['login'] == true) { ?>
Display this HTML code (without converting it to PHP echos
<?php } else { ?>
Display this instead
<?php } ?>
Or will I need to echo, and in turn escape all the required characters in order to do what I am after.
Thanks
Just try it out. But for the record, this works. And is in fact an idiomatic way of solving this.
Indented for readability (however, this messes with the HTML structure indentation so maybe it’s not appropriate).
Alternatively, the following style is often used because the lone brace at the end gets lonely:
(In both cases I’ve removed the
== truefrom the conditional because it’s utterly redundant. Don’t write== true.)