안녕 얘들 아, 내가 왜 여기 오해하니? 여기에 무엇이 잘못되었는지php directoryIterator 질문 - 잘못된 경로입니까?
[26-Apr-2011] PHP Fatal error: Uncaught exception 'RuntimeException' with message 'DirectoryIterator::__construct(http://myblog.com/wp-content/themes/mytheme/images/headers/) [directoryiterator.--construct]: failed to open dir: not implemented' in /Users/myname/htdocs/myblog.com/wp-content/themes/mytheme/inc/header-image.php:3 Stack trace:
0 /Users/myname/htdocs/myblog.com/wp-content/themes/mytheme/inc/header-image.php(3):
DirectoryIterator->__construct('http://oberperf...')
1 /Users/myname/htdocs/myblog.com/wp-content/themes/mytheme/header.php(69):
include('/Users/myname...')
2 /Users/myname/htdocs/myblog.com/wp-includes/theme.php(1112):
require_once('/Users/myname...')
3 /Users/myname/htdocs/myblog.com/wp-includes/theme.php(1088):
load_template('/Users/myname...', true)
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
on line 3
어떤 생각 :
$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을 내 놓는다?
이DirectoryIterator->__construct('http://oberperf...')
당신은 생성자에 디렉토리의 전체 로컬 경로 이름을 전달한다 : 당신이 경로 대신 URL을 전달하는 것처럼
감사합니다. 그러나 그것은 작동하지 않습니다! 정확한 코드 $ dir을 사용하면 "." 점! 거기에 경로가 없습니다. 오류가 발생하지 않습니다. 'get_template_directory()를 echo하면. '/ images/headers /''제대로 작동하지만 DirectoryIterator는 어떤 이유로 그 값을 가져 가지 않을 것입니다! – matt
DirectoryIterator 생성자에 의해 반환되는 변수가 DirectoryIterator OBJECT 인 경우에는 화면에 표시 할 수 없습니다. DirectoryIterator 문서 사용 방법에 대한 자세한 정보는 http://us.php.net/manual/en/class.directoryiterator.php를 참조하십시오. – jordanstephens