includeonce/requireonce,geting无法重新声明错误


include_once/require_once, getting cannot redeclare error

我的web服务器上有同一文件的多个版本。我需要从另一个文件中插入其中一个,并且我得到了一个"cannot redclare[function name]"错误。如果我只包含文件的一个版本,为什么会发生这种情况!?我该如何防止这个错误?

我的目录结构:

/root/subdir/index-where-I-require-files.php
/root/subdir/second-subdir/included_fileV2.php
/root/another-subdir/included_fileV1.php

我使用的是:

require_once('second-subdir/included_fileV2.php')

在我的索引文件中。

我不知道它为什么有效,但使用绝对路径而不是相对路径似乎可以解决问题。