Using a navigation bar from a seperate PHP file

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
impulse()
Forum Regular
Posts: 748
Joined: Wed Aug 09, 2006 8:36 am
Location: Staffordshire, UK
Contact:

Using a navigation bar from a seperate PHP file

Post by impulse() »

I've created a navigation bar that's held in it's own PHP file that I want to be displayed on each other page of my website but I'm having trouble outputting the file as PHP code rather than just echoing the contents of the file.
I get that output when I use

Code: Select all

readfile
. Can you suggest another way to do this?

Regards,
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

I have no idea what you are talking about. Can you post the code and try explaining again?
impulse()
Forum Regular
Posts: 748
Joined: Wed Aug 09, 2006 8:36 am
Location: Staffordshire, UK
Contact:

Post by impulse() »

I have a navigation bar, something along the lines of

Code: Select all

<table width = '80%'>
<td>
<a href = 'http://a.com'> Link  </a>
</td>
</table>
Which is stored in nav.php. I want that nav bar to be at the top of every other page.
On index.php I have:

Code: Select all

readfile("nav.php");
But it displays the contents of nav.php and I want it to use the code from nav.php so it leaves me only having to update 1 file and the changes are seen on all pages.
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

Are you looking for file_get_contents() ?
d3ad1ysp0rk
Forum Donator
Posts: 1661
Joined: Mon Oct 20, 2003 8:31 pm
Location: Maine, USA

Post by d3ad1ysp0rk »

Change it to include("nav.php");
Post Reply