SpatialVisionary, on Aug 31 2006, 08:10 AM, said:
include utilizes the unix file structure as opposed to the web server file structure.
so, let's say the unix path to your web site is /home/psgirl/public_html, when we do
include "../header.php"
it's looking for header.php in /home/psgirl (assuming we have the file with that include in a php file in public_html)
No.
Includes use what ever file structure is available to them, and relative paths are universal.
So, let's say the unix path to your web site is /home/psgirl/public_html, when we do
include "../header.php"
It's looking for header.php in the folder above what the initial file is in.
i.e.
domain.com/folder/file.php is in: /home/psgirl/public_html/folder/ and makes a call to: ../header.php, then it will look for: /home/psgirl/public_html/header.php
Of course, i didn't need to explain that, we already knew that (it's just setting me up).
PSgirl, on Aug 31 2006, 06:28 AM, said:
My structure:
/index.php
/header.php
/footer.php
/folder_to_images/hello.jpg
/folder/page2.php
/home/psgirl/public_html/ lets assume that is your directory structure (as it typically is with most sites).
According to a browser, /index.php is located in that directory. Now, if you were to say: include('/index.php'); from a php file, it would look in: ../home (note the dots and the above explaination).
Now, if you tell your browser to go to domain.com/folder/page2.php, then you have to use relative paths from within your php to access header.php, and relative paths to the images (as the browser would look for domain.com/folder/images/file.gif as opposed to domain.com/images/file.gif).
This is why most people like to use .htaccess and the query string of a url to load different pages. If the browser thinks every page is index.php, then every image/css/js file is relative to index.php, and index.php can include all the different pages you need (of course, that has it's inherit security risk, but that's so well known we need not discuss it).
And the whole point of posting this was so i would never have to again
Edited by rc69, 31 August 2006 - 08:04 PM.