proc_open
Execute a command and open file pointers for input/output.
proc_open Function synopsis
proc_open(
array|string $command,
array $descriptor_spec,
&$pipes,
?string $cwd = null,
?array $env_vars = null,
?array $options = null
)
Parameters
$command
Typearray|string
The commandline to execute as string. Special characters have to be properly escaped,
and proper quoting has to be applied.
$descriptor_spec
Typearray
An indexed array where the key represents the descriptor number and the value represents how PHP will pass that descriptor to the child process. 0 is stdin, 1 is stdout, while 2 is stderr.
$pipes
Passed by reference
Will be set to an indexed array of file pointers that correspond to PHP's end of any pipes that are created.
$cwd
OptionalType?stringDefault valuenull
The initial working dir for the command. This must be an
absolute directory path, or null
if you want to use the default value (the working dir of the current
PHP process)
$env_vars
OptionalType?arrayDefault valuenull
An array with the environment variables for the command that will be
run, or null to use the same environment as the current PHP process
$options
OptionalType?arrayDefault valuenull
Allows you to specify additional options. Currently supported options include:
Note that the parameter
$pipesis passed by reference, and contains additional/updated context data that may be useful.
Changes to the proc_open Function
PHP 8.0
- Parameter type added for parameter #1 (
$command):array|string - Parameter name of parameter #2 changed:
$descriptorspecto$descriptor_spec - Parameter type added for parameter #2 (
$descriptor_spec):array - Parameter type added for parameter #4 (
$cwd):?string - Parameter default value added for position #4 (
$cwd):null - Parameter name of parameter #5 changed:
$envto$env_vars - Parameter type added for parameter #5 (
$env_vars):?array - Parameter default value added for position #5 (
$env_vars):null - Parameter name of parameter #6 changed:
$other_optionsto$options - Parameter type added for parameter #6 (
$options):?array - Parameter default value added for position #6 (
$options):null
proc_open(
- $command,
+ array|string $command,
- $descriptorspec,
+ array $descriptor_spec,
&$pipes,
- $cwd,
+ ?string $cwd = null,
- $env,
+ ?array $env_vars = null,
- $other_options
+ ?array $options = null
) proc_open Function Availability
proc_open Function Availability| PHP Version | Availability |
|---|---|
| PHP 8.6Upcoming Release | Yes |
| PHP 8.5Supported (Latest) | Yes |
| PHP 8.4Supported | Yes |
| PHP 8.3Security-Fixes Only | Yes |
| PHP 8.2Security-Fixes Only | Yes |
| PHP 8.1Unsupported | Yes |
| PHP 8.0Unsupported | Yes |
| PHP 7.4Unsupported | Yes |
| PHP 7.3Unsupported | Yes |
| PHP 7.2Unsupported | Yes |
| PHP 7.1Unsupported | Yes |
| PHP 7.0Unsupported | Yes |
| PHP 5.6Unsupported | Yes |
| PHP 5.5Unsupported | Yes |
| PHP 5.4Unsupported | Yes |
| PHP 5.3Unsupported | Yes |