2017-09-25 4 views
-1

내 디렉토리를 가리키고 있지만 어떻게하는지 잘 모르겠습니까?php를 사용하는 디렉토리 디렉토리 폴더

if(is_dir('./anotherfolder/'.$schedule['folder'])) { 
      $schedules[$key]['files'] = array(); 
      $files = scandir('./anotherfolder/'.$schedule['folder']); 

그리고이 인덱스 파일이 디렉토리 folder/index.php에 있습니다

내 스크립트는 다음과 같다. anotherfolder/page1.php을 가리키고 싶습니다.

if (is_dir(__DIR__.'/anotherfolder/') { 

당신이 folder/index.php에있을 때 : 그때 당신과 같이 __DIR__ 대신 ..을 사용할 수 있습니다 다른 폴더

+1

당신은 PHP에서'..' 상위 폴더 선택을 사용할 수 있습니다. – rickdenhaan

+0

이렇게하면 오류 묶음이납니다 'is_dir ('../ anotherfolder/'.$ schedule [ 'folder'] ' –

+1

그게 올바른 방법입니다. 질문에 오류가 발생하면 추가하십시오.이게 작동하지 않는 것처럼 – rickdenhaan

답변

0

를 입력 폴더를 종료하고 다시 가야 의미

.

또는 당신은 PHP 파일이 해당 폴더에 있는지 확인하기 위해 file_exists을 사용할 수

if (file_exists(__DIR__.'/anotherfolder/page1.php') { 
+0

'$ files = scandir (__DIR __. ')/anotherfolder/'.$ schedule ['folder ']' –

+0

경로 앞의 폴더에 점을 추가하지 말고'/ antoherfolder /'를 사용하십시오. – divix