【发布时间】:2015-01-06 13:25:03
【问题描述】:
今天我发现从我的网站的某些部分访问我的语言文件有问题。我的结构在这里:
ROOT
|___ index.php
|___ langugages
|___ lang.cs.php
|___ lang.en.php
|___ php
|___ globals.php
|___ readDB.php
|___ writeDB.php
...
在 globals.php 我包括
include './languages/lang.' . $lang . '.php';
当从 index.php 调用 globals.php - include_once 'php/globals.php'; 时,一切正常,但我有 readDB.php,writeDB.php,它调用 include_once 'globals.php';并且由 AJAX 从 index.php 调用,在这种情况下,它包括不存在的 php/languages/lang.xx.php。您有什么想法吗,如何以正确的方式写入 lang.xx.php 的路径,以便从根目录和任何其他文件夹中使用它?
我正在考虑类似的事情
if (./languages/lang.xx.php not exists) include ../languages/lang.xx.php;
但是,这样对吗?
【问题讨论】:
-
我会检查this question out 和下面的answer out,因为这完全是一团糟。这里还有一个standard paths 101 教程。
-
太好了,非常感谢 :-)
标签: php