Here’s my problem. My code looks like this:
<ul class="nav pull-right">
<?php if (!logged_in()) : ?>
<li><a href="<?php echo base_url(); ?>login"><i class="icon-off"></i> Login</a></li>
<li><a href="<?php echo base_url(); ?>register"><i class="icon-user"></i> Register</a></li>
<?php else : ?>
<li><a href="<?php echo base_url(); ?>logout"><i class="icon-user"></i> Logout</a></li>
<?php endif; ?>
</ul>
However, when I view-source in Chrome, the code is all over the place:
<ul class="nav pull-right">
<li><a href="http://localhost/logout"><i class="icon-user"></i> Logout</a></li>
</ul>
How can I reorganise my syntax so the source looks like this?
<ul class="nav pull-right">
<li><a href="http://localhost/logout"><i class="icon-user"></i> Logout</a></li>
</ul>
Every carriage-return after a closing PHP Tag is not returned to the output buffer. You have to add some extra lines to your code like this:
You may want to have a look at Twig which is a templating system. It also has functions to remove all spaces which is sometimes very handy.