Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.
Output the $scriptname variable to see what it is being set to because obviously the if statements are never returning true. Using the below bit of code with yours will put the first menu item as the $scriptname variable just to make it a little easier to see on your page.

PHP:
<?php
$scriptname = basename(__FILE__);
echo '<li>', $scriptname, '</li>';
...

Also, you may want to check out your PHP error log. Something may be coming up in there.

/Applications/MAMP/logs/php_error.log
 
Thanks for that, think we're getting to the problem now (thanks to your help). The filename being outputted with your suggestion is 'top.php' which makes sense now (by the way thanks for showing me how to write the last bit, wasn't aware comma's were needed.
I think top.php is being outputted because I have created a template called top.php and this contains my nav bar, various javascripts, and my sidebar etc. Which is cool so I control the layout of all my pages without having to mess around editing ten or twenty pages.
top.php is being called at the begining of one of all of my pages, so this must be playing with the way php interperets the files being used.
This is how I have it on top.php
PHP:
<?php
$scriptname = basename(__FILE__);
echo '<li>';
	if ($scriptname == 'index.php') {
		echo '<a href="index.php" class="highlight">home</a>';	
	} else {	
		echo '<a href="index.php">home</a>';
	}	
echo '</li>';
echo '<li>';
	if ($scriptname == 'services.php') {
		echo '<a href="services.php" class="highlight">services</a>';	
	} else {	
		echo '<a href="services.php">services</a>';}	
echo '</li>';
echo '<li>';
	if ($scriptname == 'portfolio.php') {
		echo '<a href="portfolio.php" class="highlight">portfolio</a>';	
	} else {	
		echo '<a href="portfolio.php">portfolio</a>';}	
echo '</li>';
echo '<li>';
	if ($scriptname == 'links.php') {
		echo '<a href="links.php" class="highlight">links</a>';	
	} else {	
		echo '<a href="links.php">links</a>';}	
echo '</li>';
echo '<li><a href="http://www.preciseformwork.co.uk/wordpress">blog</a></li>';
echo '<li class="no-pad">';
	if ($scriptname == 'contact.php') {
		echo '<a href="contact.php" class="no-pad">contact us</a>';	
	} else {	
		echo '<a href="contact.php" class="no-pad">contact us</a>';}	
echo '</li>';
?>
</ul>
</div>
and in my page called slabs.php we include the whole top.php document (not all of it is visible here only the list thingy to see what page we're on.
PHP:
<?php
$pagetitle='Reinforced Concrete Slabs';
include 'top.php';
Thanks
?>
 
Yes, that makes sense. That's why I often don't use the __FILE__ in my code. Here's some code that will bypass that issue.

PHP:
$scriptname = basename($_SERVER['PHP_SELF']);

As for the commas with the echo statement. You can use either commas or the dot (string concatenation). Neither one is more correct than the other. The commas weren't "needed" for the statement.
 
Great, that's got it. Thank you very much. Well chuffed.:) much appreciated.
I have been reading php file over and over for previous two weeks, and I was aware of PHP SELF command but I still don't understand the difference in them.
Find it quite awkward and hard to find information on php manual. Can't beat a book.
Thanks again :)
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.