$dir = get_bloginfo('template_url').'/images/headers/';
echo $dir;
//ouput: myblog.com/wp-content/themes/mytheme/images/headers
$dir = new DirectoryIterator(get_bloginfo('template_url').'/images/headers/');
echo $dir;
//output: nothing at all! blank page!
控制台发出了fatal_error:
[2011年4月26日] PHP致命错误: 未捕获的异常'RuntimeException' 与消息 “DirectoryIterator :: __构建体(http://myblog.com/wp-content/themes/mytheme/images/headers/) [directoryiterator .--构造]: 未能打开目录:未实施' 在 /Users/myname/htdocs/myblog.com/wp-content/themes/mytheme/inc/header-image.php:3 堆栈跟踪:
0 /Users/myname/htdocs/myblog.com/wp-content/themes/mytheme/inc/header-image.php(3):
DirectoryIterator-> __构建体( 'HTTP:// ... oberperf')
1 /Users/myname/htdocs/myblog.com/wp-content/themes/mytheme/header.php(69):
包括( '/用户/ MYNAME ...')
2 /Users/myname/htdocs/myblog.com/wp-includes/theme.php(1112):
require_once( '/用户/ MYNAME ...')
3 /Users/myname/htdocs/myblog.com/wp-includes/theme.php(1088):
load_template( '/用户/ MYNAME ...', 真)
4 /Users/myname/htdocs/myblog.com/wp-includes/general-template.php(34):
locate_template(Array,true)
5 / Users / myname in /Users/myname/htdocs/myblog.com/wp-content/themes/mytheme/inc/header-image.php
第3行
知道这里出了什么问题吗?
答案 0 :(得分:1)
看起来您正在传递网址而不是路径:
DirectoryIterator->__construct('http://oberperf...')
您应该将目录的完整本地路径名传递给构造函数。
答案 1 :(得分:0)
我很确定路径必须是文档根目录的绝对路径,而不是URL。
$dir = new DirectoryIterator( get_template_directory() . '/images/headers/');
echo $dir;