我在主文件夹中有一个文件a.php,两个文件b.php和c.php在一个child_folder中。 这三个文件的内容在
之下a.php
<?php
require 'child_folder/b.php';
?>
b.php (within child folder)
<?php
require 'c.php';
require 'child/c.php';
?>
c.php (within child folder)
<?php
echo 'this is c file<br>';
?>
当我运行a.php时,它会回显以下输出
这是c文件
这是c文件
用文件b调用文件c的正确方法是什么,天气它应该被称为w.r.t文件或w.r.t b文件..?
答案 0 :(得分:0)
执行此操作的最佳方法是在“include”中提供文件的绝对路径。这不会与嵌套目录混淆,您也可以将其从文件复制并粘贴到文件中。
define("CURRENT_PATH", dirname(__FILE__)); // This defines the path as the directory the file is in.
include(CURRENT_PATH . "/path/to/file");