- <?php
- /*
- 파일 11.php와
- 파일 22.php가 있다는 가정입니다.
- */
- // exec()함수;
- echo "exec()함수<br>\n";
- if(exec("ls",$outArray)){
- // ls는 리눅스에서 파일 리스트 출력 명령어 입니다.
- echo $outvalue."<br>\n";
- for($i = 0; $i < count($outArray); $i++){
- echo $outArray[$i]."<br>\n";
- } // for문 끝
- }
- else{
- echo "exec()함수 실패<br>\n";
- }
- /* 출력 내용
- exec()함수
- 11.php
- 22.php
- */
- ?>
--------------------------------------------------------------------------------------------
string exec ( string $command [, array &$output [, int &$return_var ]] )
9. 라인
$command에 리눅스 명령어를 넣으면
로컬 시스템에서 실행이 되며, &$output배열에 실행결과값을 반환합니다.
비슷한 함수로는 system()함수와 shell_exec()가 있습니다.
'php5 > 파일관련함수' 카테고리의 다른 글
파일 존재 확인 - bool file_exists ( string $filename ) (0) | 2014.01.10 |
---|---|
파일 복사 - bool copy ( string $source , string $dest ) (0) | 2014.01.10 |
시스템 명령어 실행1 - string system ( string $command ) (0) | 2014.01.10 |
파일 경로 반환 - string dirname ( string $path ) (0) | 2014.01.09 |
파일의 현재 작업 디렉토리 반환 - string getcwd ( void ) (0) | 2014.01.09 |