我的include()
通过include(bloginfo('template_directory') . '/home_bloc_horaires.php');
工作(尽管这会在屏幕上显示我显然不想要的路径)。
但是include(get_stylesheet_directory_uri().'/home_bloc_horaires.php');
失败并产生错误:
Warning: include(): http:// wrapper is disabled in the server configuration by allow_url_include=0 in D:\EasyPHP\www\wordpress\wp-content\themes\mmt-2014\header.php on line 348
Warning: include(http://127.0.0.1/wordpress/mirail/wp-content/themes/mmt-2014/home_bloc_horaires.php): failed to open stream: no suitable wrapper could be found in D:\EasyPHP\www\wordpress\wp-content\themes\mmt-2014\header.php on line 348
Warning: include(): Failed opening 'http://127.0.0.1/wordpress/mirail/wp-content/themes/mmt-2014/home_bloc_horaires.php' for inclusion (include_path='.;C:\php\pear') in D:\EasyPHP\www\wordpress\wp-content\themes\mmt-2014\header.php on line 348
然而,echo get_stylesheet_directory_uri().'/home_bloc_horaires.php';
显示了有效的功能路径。有什么解释吗?
答案 0 :(得分:2)
使用get_stylesheet_directory()
代替get_stylesheet_directory_uri()
。
get_stylesheet_directory()
返回目录路径(文件系统路径)。
get_stylesheet_directory_uri()
返回目录(Web路径)的URI