Directory issues!
I have a directory problem.
If i have a file in the fol开发者_StackOverflow社区lowing 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.
精彩评论