简体   繁体   English

获取PHP的尝试路径,包​​括

[英]Get Tried Paths for PHP's include

Is it in any way possible to tell PHP that I want to have a list of tried paths whenever include fails? 是否可以以任何方式告诉PHP我希望在include失败时有一个已尝试路径的列表? The file is there, yet PHP is telling me the include failed. 该文件在那里,但是PHP告诉我include失败。

You can use get_include_path() to find out what paths have been used by the include / require methods to source files. 您可以使用get_include_path()来找出include / require方法使用了哪些路径来获取源文件。

It's a setting in php.ini (of course overridable by your application) that determines where these methods should look. 这是php.ini的设置(当然可以被您的应用程序覆盖),该设置确定这些方法的外观。 They won't look anywhere else. 他们不会在别处看。

If you need these methods to look elsewhere, simply append another folder path with PATH_SEPARATOR , like so: 如果您需要这些方法在其他地方查找,只需将另一个文件夹路径附加PATH_SEPARATOR ,如下所示:

set_include_path(get_include_path() . PATH_SEPARATOR . $newPath);

The only paths it checks are the include paths. 它检查的唯一路径是包含路径。 You can just use get_include_path . 您可以只使用get_include_path

 $dirs = explode(PATH_SEPARATOR, get_include_path());

More information on the include path setting here . 有关包含路径设置的更多信息,请参见此处

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM