I've been having a problem using includes. I use repeated code in my includes for things like navigation bars that will appear on every page. However, when I look at the resulting source code on the website using the include, the code from the include always looks very messy and loses its nesting and indentation. How can I fix this? Here's an example from my portfolio site:
http://www.hendeca.com/web.php
This site uses the following include:
Code: Select all
<?php
$currentPage = basename($_SERVER['SCRIPT_NAME'], '.php');
$brianmatch = '/brianmeehl/';
$fouredgematch = '/fouredge/';
$transmatch = '/transparencyfight/';
$connormatch = '/chooseconnor/';
?>
<ul id="weblist">
<?php if(!preg_match($connormatch, $currentPage)) {?><li><a href="web.chooseconnor.php">Choose Connor.com</a></li><?php } else {?> <li class="current">Choose Connor.com</li> <?php } ?>
<?php if(!preg_match($brianmatch, $currentPage)) {?><li><a href="web.brianmeehl.php">Brian Meehl.com</a></li><?php } else {?> <li class="current">Brian Meehl.com</li> <?php } ?>
<?php if(!preg_match($fouredgematch, $currentPage)) { ?><li><a href="web.fouredge.php">The Four Edge.com</a></li><?php } else {?> <li class="current">The Four Edge.com</li> <?php } ?>
<?php if(!preg_match($transmatch, $currentPage)) {?><li><a href="web.transparencyfight.php">Transparency Fight.com</a></li><?php } else {?> <li class="current">Transparency Fight.com</li> <?php }?>
</ul>
-Neal