테스트 사이트 - 개발 중인 베타 버전입니다

common.php에 php파일 인클루드 하는 소스에 대해 질문이 있습니다. 채택완료

권영민 8년 전 조회 3,748

$extend_file = array();

$tmp = dir(G5_EXTEND_PATH);

while ($entry = $tmp->read()) {

    // php 파일만 include 함

    if (preg_match("/(\.php)$/i", $entry))

        $extend_file[] = $entry;

}

 

위 소스에서

$entry = $tmp->read() 해당구문에 대해서 정확이 이해가 가지를 않아서 질문을 드립니다.

그리고 $entry가 어떤걸 담고 있는 것입니까??

댓글을 작성하려면 로그인이 필요합니다.

답변 3개

채택된 답변
+20 포인트
F
8년 전

</strong> </p><p style="word-break: break-all; color: rgb(72, 72, 72); font-family: 돋움, Dotum, sans-serif; font-size: 14.004px; line-height: 25.2072px;">$extend_file = array();</p><p style="word-break: break-all; color: rgb(72, 72, 72); font-family: 돋움, Dotum, sans-serif; font-size: 14.004px; line-height: 25.2072px;">$tmp = dir(G5_EXTEND_PATH);</p><p style="word-break: break-all; color: rgb(72, 72, 72); font-family: 돋움, Dotum, sans-serif; font-size: 14.004px; line-height: 25.2072px;">while ($entry = $tmp->read()) {</p><p style="word-break: break-all;"><font color="#484848" face="돋움, Dotum, sans-serif"><span style="font-size: 14.004px; line-height: 25.2072px;"><span class="Apple-tab-span" style="white-space: pre;">	</span>var_dump($entry); // 뭘 담앗는지 출력하기</span></font></p><p style="word-break: break-all;"><font color="#484848" face="돋움, Dotum, sans-serif"><span style="font-size: 14.004px; line-height: 25.2072px;"><span class="Apple-tab-span" style="white-space: pre;">	</span>echo '
';</span></font></p><p style="word-break: break-all; color: rgb(72, 72, 72); font-family: 돋움, Dotum, sans-serif; font-size: 14.004px; line-height: 25.2072px;">    // php 파일만 include 함</p><p style="word-break: break-all; color: rgb(72, 72, 72); font-family: 돋움, Dotum, sans-serif; font-size: 14.004px; line-height: 25.2072px;">    if (preg_match("/(\.php)$/i", $entry))</p><p style="word-break: break-all; color: rgb(72, 72, 72); font-family: 돋움, Dotum, sans-serif; font-size: 14.004px; line-height: 25.2072px;">        $extend_file[] = $entry;</p><p style="word-break: break-all; color: rgb(72, 72, 72); font-family: 돋움, Dotum, sans-serif; font-size: 14.004px; line-height: 25.2072px;">}</p><p style="word-break: break-all; color: rgb(72, 72, 72); font-family: 돋움, Dotum, sans-serif; font-size: 14.004px; line-height: 25.2072px;"><strong style="color: rgb(127, 127, 127); font-size: 13.3333px; line-height: normal;">
 

직접출력해보심 알것같은데요 , var_dump 요거루요 

로그인 후 평가할 수 있습니다

댓글을 작성하려면 로그인이 필요합니다.

dir() 얘가 생긴 건 딱 함순데 실제로는 클래스예요. read(), rewind(), close() 세 가지 멤버 함수가 있습니다. 이 셋은 php 내장 함수 readdir(), rewinddir(), closedir() 이 세 가지랑 동일한 역할을 합니다. http://php.net/manual/kr/function.readdir.php">http://php.net/manual/kr/function.readdir.php extend 디렉토리를 읽은 후에 확장자가 .php인 애들만 찾은 후에 $extend_file이라는 배열에 하나씩 담습니다.
로그인 후 평가할 수 있습니다

댓글을 작성하려면 로그인이 필요합니다.

그누위즈

$entry라고 변수를 그냥 하나 생성한겁니다. 

$entry변수에는 $tmp->read() 

즉 .php 파일명이 하나씩 들어갑니다.

그렇게해서 $extend_file[] 배열에 순차적으로 담아냅니다.

로그인 후 평가할 수 있습니다

댓글을 작성하려면 로그인이 필요합니다.

답변을 작성하려면 로그인이 필요합니다.

로그인