1

I just started working on a site that has been passed down to me that isn't working. I've found that there's a problem when in /admin/index.php it tries to instantiate an instance of /classes/admin.php. However, if I copy /admin/index.php to /admin-index.php, it can instantiate the class just fine. Also, if I move /classes/admin.php into /admin/classes/admin.php, I can also instantiate it just fine. There is at least one other class that I've noticed this with.

I've also noticed that this isn't a problem on my local development machine. It's only an issue on the server.

You can find info about the server at http://charlesekublyfoundation.org/admin/phpinfo.php. My development machine is a WinXP machine running Apache 2.2 and PHP 5.2.11 (Apache/2.2.14 (Win32) PHP/5.2.11 ).

Has anyone seen anything like this? It seems odd. I'm fairly new to PHP development (primarily .NET developer), so I'm not sure what would cause this. I'm not sure if it's a difference in PHP or Apache or something else.

EDIT I should note that my server is running on some brand of Linux while by dev machine is Windows. I'm having a feeling that has something to do with this after looking into include_paths.

4

2 回答 2

2

我能想到的有几件事可能与这个问题有关。

根据您的描述,我认为最有可能的是开发人员依赖 PHP 的include_path设置。此设置与require()include()命令一起使用,以告诉他们在未提供硬路径的情况下在哪里查找请求的文件。如果代码使用相对路径,并且include_path设置不同,则可能会出现问题。通常,include_path将包含“当前目录”(即,.)作为路径的一部分,并且包含是使用它作为基础完成的。

另一种可能性是应用程序正在使用自动加载,并且不知何故这没有正确地转换为生产。我会在应用程序中快速搜索一下,看看是否有__autoload()指定的功能,或者spl_autoload_register()是否使用过。如果是这样,也许自动加载功能正在做出仅在开发机器上正确的目录假设?

于 2010-01-29T18:34:25.840 回答
0

您应该检查包含路径以了解它为什么不能正常工作。包含路径信息将位于您的 PHP 配置文件(通常是 php.ini)以及应用程序本身中。在应用程序中,您可以尝试使用函数 get_include_path 并打印出它返回的内容。

于 2010-01-29T18:38:48.613 回答