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
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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.