Php includes in folder indexes.

  • suforum
  • Newbie
  • Newbie
  • suforum
  • Posts: 6

Post 3+ Months Ago

Well In my public_html folder I have a header php file and a footer php file.

In my index page I use php inlcudes to include my files.

My question is when i make a new folder how can i put includes into the index of the folder. Becaue I want to have instead of

The only way that worked for me was in the include for the url i put

/home/mysite/mypath/*.php and in the stylsheet in header php i had to
put the stylesheet url as

So i was just wondering if there were any better ways to work around it.

O and dont want to put the php files in each folder because that would defeat the purpose of includes.
  • ScienceOfSpock
  • Mastermind
  • Mastermind
  • User avatar
  • Posts: 1893
  • Loc: Las Vegas

Post 3+ Months Ago

The easiest way is to use a basepath var at the top of each script:
Code: [ Select ]
$basepath = "/home/mysite/mypath/";
require_once ( $basepath . "header.php" );
// page content here
require_once ( $basepath . "footer.php" );
  1. $basepath = "/home/mysite/mypath/";
  3. require_once ( $basepath . "header.php" );
  5. // page content here
  7. require_once ( $basepath . "footer.php" );

Using that code, it doesn't matter where your script is and the includes will always work (so long as they're present)

Post Information

  • Total Posts in this topic: 2 posts
  • Users browsing this forum: No registered users and 41 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum

© 1998-2017. Ozzu® is a registered trademark of Unmelted, LLC.