【发布时间】:2013-07-14 23:18:59
【问题描述】:
我有一个具有以下目录结构的网站:
index.php
connections/database.php
contacts/details.php
inc/functions.php
我希望 database.php 页面使用 require_once 来包含 functions.php 页面,例如:
require_once 'inc/functions.php';
然后我想对 index.php 页面和 details.php 页面都使用 require_once 来只需要 database.php 页面,而该页面又将包含 functions.php 页面。我可以在 index.php 页面或 details.php 页面上使用它,但不能同时用于两者,因为我必须不断更改语法,例如
require_once 'inc/functions.php';
require_once '../inc/functions.php';
否则我会收到无法找到 functions.php 页面的错误。有没有办法包含 database.php 页面,该页面还包含可以在 index.php 页面和contacts/details.php 页面的不同目录中工作的functions.php 页面?
谢谢
【问题讨论】: