Forum und email

passthru

(PHP 4, PHP 5)

passthru — Execute an external program and display raw output

Beskrivelse

void passthru ( string $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.

Parameterliste

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.

Returneringsværdier

Ingen værdi er returneret.

Notes

Warning

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 systemet til at eksekvere fjendtlige kommandoer.

Note: 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 omdirigeret til en fil eller en anden output stream, ellers vil hænge indtil udførelsen af programmet er færdig.

Note: 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.

Warning

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".