PHP包含错误:无法打开文件以包含

时间:2015-11-10 07:46:16

标签: php wordpress

尝试在WordPress主题的函数文件中包含文件时出现以下错误:

Warning: include_once(/var/www/html/etc/wp-content/themes/etc/inc/site_footer.php): failed to open stream: No such file or directory in /var/www/html/etc/wp-content/themes/etc/functions.php on line 202

Warning: include_once(): Failed opening '/var/www/html/etc/wp-content/themes/etc/inc/site_footer.php' for inclusion (include_path='.:/usr/share/php:/usr/share/pear') in /var/www/html/etc/wp-content/themes/etc/functions.php on line 202

基于其他主题,我尝试通过以下所有方式添加它:

include_once( get_stylesheet_directory() . '/inc/site_footer.php' );
include_once( get_bloginfo( 'stylesheet_directory' ) . '/inc/site_footer.php' );
include_once( $_SERVER['DOCUMENT_ROOT'] . '/inc/site_footer.php' );
include_once( dirname(__FILE__) . '/inc/site_footer.php' );
include_once( __DIR__ . '/inc/site_footer.php' );
include_once( dirname(FILE) . '/inc/site_footer.php' );
file_get_contents( get_stylesheet_directory() . '/inc/site_footer.php' );

他们都没有工作。

我还尝试了绝对路径,看看是否可行:

include_once( '/var/www/html/etc/wp-content/themes/etc/inc/site_footer.php' );

它没有。

我也尝试在php.ini文件中修改allow_url_include。它被设置为allow_url_include = Off。我试过了以下内容:

allow_url_include = On
allow_url_include = 1

我在同一台计算机上的其他WordPress安装中进行了相同的include_once( get_stylesheet_directory() . '/inc/site_footer.php' );调用,无问题。事实上,因为这是一个Genesis儿童主题,所以在同一个函数文件的顶部有一个include_once( get_template_directory() . '/lib/init.php' );调用,可以正常工作。

为什么这个WordPress的安装会有所不同以及如何解决这个问题?

0 个答案:

没有答案
相关问题