Jump to content

Help needed on file directory structure


parka

Recommended Posts

I've a submit.php in the directory

 

/classifieds/submit.php

/inc

index.php

 

<?php
//submit.php

require_once('../inc/include_fns.php');
?>

 

When I switch the path inside require_once() to root relative, it doesn't work.

Apparently, it must have jumped even further up the hierarchy.

 

require_once('/inc/include_fns.php');

 

So I'm guessing the root directory PHP is seeing is not what I think it is.

 

On my computer, the actual file path is

/Macintosh HD/Users/MyName/Sites/htdocs/MySite/classifieds/submit.php

 

I need my root directory to be "MySite".

But how can I get PHP to realise what root directory I want?

Link to comment
https://forums.phpfreaks.com/topic/96648-help-needed-on-file-directory-structure/
Share on other sites

file.php = a file in the same directory

/file.php = a file in the same folder as your homepage (aka, localhost)

./file.php = a file in the same directory

../file.php = a file in 1 directory back

../../file.php = a file in 2 directories back

../../../file.php = a file in 3 directories back

etc.

 

Of course, you could use $_SERVER predefined variables - Click Here

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.