Execute an external program and display raw output (original) (raw)

passthru

(PHP 4, PHP 5, PHP 7)

passthru — Execute an external program and display raw output

Description

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

Parameters

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.

Return Values

No value is returned.

Notes

Warning

When allowing user-supplied data to be passed to this function, useescapeshellarg() or escapeshellcmd()to ensure that users cannot trick the system into executing arbitrary commands.

Note:

If a program is started with this function, in order for it to continue running in the background, the output of the program must be redirected to a file or another output stream. Failing to do so will cause PHP to hang until the execution of the program ends.

Note: Whensafe mode is enabled, you can only execute files within the safe_mode_exec_dir. For practical reasons, it is currently not allowed to have ..components in the path to the executable.

Warning

With safe mode enabled, the command string is escaped with escapeshellcmd(). Thus,echo y | echo x becomes echo y \| echo x.

See Also