Jump to content

Calling Sub Files in PHP


CoachKip

Recommended Posts

I hope that the subject title got your attention.  I don't know how to put it under one subject but here is what I want to do:

 

I want to have many pages all looking the same.  Basically setting up a template for my site.

 

What I want to do is have say index.php.  Inside index.php I want to have calls that bring up a right_nav and left_nav, header, ect.  I want it to look the same over the entire site.  What I don't want to do is when I make a change to the right_nav (navigation section) I don't want to make it on every single page.  I want to make the change in the nav file and have it in a seperate file, that I can call up on every single other page.

 

Sorry if I am not to clear, I am not a programmer, I am just trying to make things easy on myself.

 

Thanks

 

Coach Kip

Link to comment
https://forums.phpfreaks.com/topic/46010-calling-sub-files-in-php/
Share on other sites

Use the include() function for each of the common elements.

 

<?php include("right_nav.php");

 

Insert that statement exactly where you want the right_nav to appear. right_nav.php should contain only the html needed, i.e. no head/body/etc tags.

 

Think of include like copy/paste by the server.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.