我在PHP嘗試,想知道我怎麼能在WordPress文件做這樣的事如何包含在PHP文件,還是尊重不同於相對鏈接包含的文件
if (site is wordpress)
include wordpress index.php;
有一條線
require('./wp-blog-header.php');
這不會工作,因爲它拋出我找不到文件錯誤,它會工作,但如果我將其更改爲這個
require('wp-blog-header.php');
然後我沒有得到一個問題和頁面加載(以及一些擴展,因爲wp-blog-header.php加載在一些其他文件相對於wp-blog-header.php所以那些不要包含或加載)。
有什麼辦法可以讓PHP保持並尊重相關文件嗎?
編輯:包括我對我的問題
if ($app['framework']['type'] && $app['cms']['type']) {
echo "Only a Framework or CMS can be loaded at a time...";
} else {
if (is_file("./app/" . $cfg['application']['name'] . "/index.php")) {
require_once "./app/" . $cfg['application']['name'] . "/index.php";
} else {
if ($app['framework']['type']) {
echo "framework";
//require_once "./app/" . $cfg['application']['name'] . "/" . $app['framework']['type'] . "/index.php";
} else if ($app['cms']['type']) {
if ($admin) {
require_once "./app/" . $cfg['application']['name'] . "/" . $app['cms']['type'] . "/wp-admin/index.php";
} else {
$old_working_dir = getcwd(); // Remember where we are now.
chdir("./app/" . $cfg['application']['name'] . "/" . $app['cms']['type'] . "/"); // 'Go into' the Wordpress directory.
//include("index.php"); // Include the index.php file (no need for 'wordpress/')
chdir($old_working_dir);
require_once "index.php";
}
} else {
echo "There is no index in your project directory, if your going to use a Framework or CMS please choose one from the following, thank you (list of cms's and frameworks)";
}
}
exit;
}
鏈接或文件名? –
文件名,例如包括(「some-other-file.php」) – Eli