简体   繁体   中英

Directory issues!

I have a directory problem.

If i have a file in the following place.

public_html/v3/index.php

And within that I want to reach the following

public_html/navigation/sideLogIn.php

I have used the following:

include("/navigation/sideLogIn.php");

For some reason, that code isn't finding what I expect. What am I doing wrong? I assumed / went to root?

Thanks

EDIT.

The following also doesnt seem to want to work, any ideas.

        echo '<img src="$_SERVER[DOCUMENT_ROOT]/images/users/tiny.jpg" alt="" />';

Thanks

I would suggest using $_SERVER['DOCUMENT_ROOT'] as your root. This way, whether you are developing on your home computer or the script is running on the server, the document root will change automatically.

include($_SERVER['DOCUMENT_ROOT'] . '/navigation/sideLogin.php');

Also, it is a good idea to use single quotes in this situation as php tries to parse the script for variables if you use double quotes.

You can use:

include($_SERVER['DOCUMENT_ROOT'].'/navigation/sideLogIn.php');

this is the same as /fromroot/public_html/navigation/sideLogIn.php

If you want an absolute directory, instead of a relative one, use

~/public_html/navigation/sideLogIn.php

~ will give you your home directory, through it looks weird and isn't usually used from a webpage perspective.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM