<?php include "QUESTION" ?>
5 posts by 3 authors in: Forums > CMS Builder
Last Post: July 19, 2012 (RSS)
By kdub718 - July 18, 2012 - edited: July 18, 2012
I try and keep files organized and have them in proper directories.
With that said I'm trying to use and it works perfectly
<?php include "file-name.php" ?>
But in order for that to work I have to have that "file-name.php" in every directory.
I was trying to use
<?php include "../file-name.php" ?>
To point it back to the main directory so I don't have to have that "file-name.php" in every folder but it won't work.
I was wondering if I'm just doing it wrong or if it's not possible to do that?
Thanks
Re: [kdub718] <?php include "QUESTION" ?>
By Jason - July 18, 2012
If the directory you are in is only 1 level below the root, that code should work. To help keep things even more organize, a good practice is to create a folder in the root called "includes". You can then put all the files that get included on other pages into that directory.
So if you then were in a sub directory, and wanted to include "file-name.php", you would use this:
<?php include ("../includes/file-name.php"); ?>
Let me know if that works for you.
Jason Sauchuk - Project Manager
interactivetools.com
Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/
Re: [Jason] <?php include "QUESTION" ?>
By kdub718 - July 18, 2012
Re: [kdub718] <?php include "QUESTION" ?>
By Toledoh - July 18, 2012
<base href="http://www.yourdomain.com/" target="_self" />
and then have all links relative to the base URL?
Tim (toledoh.com.au)
Re: [kdub718] <?php include "QUESTION" ?>
By Jason - July 19, 2012
What you can do is include all your CSS in your main page, not your included page. The PHP include just "inserts" the code from an external page into the including page. So any CSS rules set up in the including page will apply.
Hope this helps
Jason Sauchuk - Project Manager
interactivetools.com
Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/