Let's say I have two folders in my PHP server root directory: x
and y
. There are two more directories inside the x
folder: a
and b
. In the /x/a
directory I have the index.php
file and in the /y
folder a stuff.php
file.
From my /x/a/index.php
file, I want to include the /y/stuff.php
file. How do I do that?
My server doesn't allow including files from other domains, so adding the full URL doesn't work! Also, I'd like to know how to start a path from the root in PHP. I use ./blabla
from the index of my root and ../blabla
from directories in the root, but, unfortunately, .../blabla
doesn't work from 2nd grade directories.
To access the root begin your path with "/".
If you want to go up one directory from where you are currently, eg from /x/a/ to /x/ you could use "../".
If you want to go back up two directories (eg from /x/a/ to /) you could use "../../" (rather than ".../" which you mentioned).
尝试:
include "../../y/stuff.php";
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.