passthru

(PHP 3, PHP 4 , PHP 5)

passthru --  Execute an external program and display raw output

Description

void passthru ( string command [, int &return_var])

The passthru() function is similar to the exec() function in that it executes a command. If the return_var argument is present, the return status of the Unix command will be placed here. 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.

Advarsel

Hvis du vil tillade data fra bruger input til at blive viderebragt til denne funktion, så bør du bruge escapeshellarg() eller escapeshellcmd() til at sikre at brugere ikke kan snyde systemmet til at eksekvere fjendtlige kommandoer.

Bemærk: Hvis du starter et program ved brug af denne funktion og ønsker at lade det køre i baggrunden, skal du sørge for at outputtet fra det program er redirected til en fil eller en anden output stream, ellers vil hænge indtil udførelsen af programmet er færdig.

Bemærk: Når safe mode er aktiveret, kan du kun eksekvere eksekverbare filer inden for safe_mode_exec_dir. Af praktiske årsager er det pt. ikke tilladet at have .. komponenter i stien til den eksekverbare fil.

Advarsel

Med safe mode aktiveret, vil alle ord efterfølgende den oprindelige kommandostreng blive behandlet som et enkelt argument. Derfor, echo y | echo x bliver echo "y | echo x".

See also exec(), system(), popen(), escapeshellcmd(), and the backtick operator.