(PHP 4, PHP 5, PHP 7)
passthru — Execute an external program and display raw output
$command
[, int &$return_var
] )
The passthru() function is similar to the
exec() function in that it executes a
command
. This function
should be used in place of exec() or
system() when the output from the Unix command
is binary data which needs to be passed directly back to the
browser. A common use for this is to execute something like the
pbmplus utilities that can output an image stream directly. By
setting the Content-type to image/gif and
then calling a pbmplus program to output a gif, you can create
PHP scripts that output images directly.
command
The command that will be executed.
return_var
If the return_var
argument is present, the
return status of the Unix command will be placed here.
값을 반환하지 않습니다.
사용자가 입력한 데이터를 이 함수로 넘길 때는, escapeshellarg()나 escapeshellcmd()를 이용하여, 사용자가 위험한 명령을 실행하는 조작을 하지 못하게 해야 합니다.
Note:
백그라운드에서 실행하기 위해서 이 함수로 프로그램을 시작하면, 프로그램의 출력은 파일이나, 다른 출력 스트림으로 보내야 합니다. 그렇지 않으면, 프로그램이 종료할 때까지 PHP가 멈출 수 있습니다.
Note: 안전 모드에서 실행 명령은 safe_mode_exec_dir 안에서만 실행할 수 있습니다. 실용적인 이유로, 현재는 실행 경로에 ..을 허용하지 않습니다.
안전 모드에서 명령어는 escapeshellcmd()로 회피처리됩니다. 그러므로, echo y | echo x는 echo y \| echo x가 됩니다.