Ok guys, i was wondering: How could i access every file by every file in the same way. I mean, let's say i have this folder & files schema:
A/index.php
A/B/file1.php
A/B/famous.php
A/B/C/file2.php
I'd like to be able to do something like this:
index.php
include('开发者_JAVA技巧B/famous.php');
file1.php
include('B/famous.php');
file2.php
include('B/famous.php');
How to do that?
You could include it trough an absolute path. Or make a config file what defines this absolute path, and put it in the root
so you'd do
include('/config.php');
include(BASEPATH.'B/famous.php');
config.php would have something like this in it
define(BASEPATH, "/var/www/myDomain/mySite");
Add /path/to/A/B
to your PHP installation's php.ini
include_path
directive.
Give each root file a variable $root_path = ../;
(changed corresponding to the level the script is at, then your include statement will look like include($root_path . "B/famous.php");
精彩评论