Jump to content

Directory Structure using Sub directories


SharkBait

Recommended Posts

Ok I am having some weird thinking issues and trying to make a website more... universal throughout so hopefully I can explain it well enough to hopefully get some help with it.

 

/index.php

/mysql_connect.php

/funcs.php

/includes/header.html

/includes/footer.html

/products/index.php

 

Ok take that as an example. I want to be able to create a 'global' variable that i can set in /includes/header.html that will allow me to have /products/index.php require /includes/header.html and /includes/footer.html properly.

 

/includes/header.html also includes /mysql_connect.php and /funcs.php

 

Or are /mysql_connect.php and /funcs.php in the wrong place for this to work properly?

 

when i add require('/includes/header.html"); and require("/includes/footer.html"); in the /products/index.php file. I get errors that it can not find the /mysql_connect.php file nor the /funcs.php file.

 

Does this make sense??

A leading slash on a file system path, like in your examples, refers to the root of the current hard drive.

 

I recommend using absolute file system paths that will work independent of the current working directory and independent of the include_path setting.

 

require($_SERVER['DOCUMENT_ROOT'] . "/includes/header.html");

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.