pcntl_exec

FunctionReturn type changed in PHP 8.5

Executes specified program in current process space.

PHP 5
PHP 7
PHP 8.0
Improved
PHP 8.1-8.2
PHP 8.3
PHP 8.4
PHP 8.5
Improved
PHP 8.6

pcntl_exec Function synopsis

pcntl_exec(
    string $path,
    array $args = [],
    array $env_vars = []
  ): false

Parameters

$path

Typestring

$path must be the path to a binary executable or a script with a valid path pointing to an executable in the shebang ( #!/usr/local/bin/perl for example) as the first line. See your system's man execve(2) page for additional information.

$args

OptionalTypearrayDefault value[]

$args is an array of argument strings passed to the program.

$env_vars

OptionalTypearrayDefault value[]

$env_vars is an array of strings which are passed as environment to the program. The array is in the format of name => value, the key being the name of the environmental variable and the value being the value of that variable.

Return value

Typefalse

Returns false.

Changes to the pcntl_exec Function

PHP 8.5

  • Return type changed: bool to false
  pcntl_exec(
      string $path,
      array $args = [],
      array $env_vars = []
-   ): bool
+   ): false

PHP 8.0

  • Return type added: bool
  • Parameter type added for parameter #1 ($path): string
  • Parameter type added for parameter #2 ($args): array
  • Parameter default value added for position #2 ($args): []
  • Parameter name of parameter #3 changed: $envs to $env_vars
  • Parameter type added for parameter #3 ($env_vars): array
  • Parameter default value added for position #3 ($env_vars): []
  pcntl_exec(
-     $path,
+     string $path,
-     $args,
+     array $args = [],
-     $envs
+     array $env_vars = []
-   )
+   ): bool

pcntl_exec Function Availability

PHP VersionAvailability
PHP 8.6Future Release Yes
PHP 8.5Upcoming Release Yes
PHP 8.4Supported (Latest) Yes
PHP 8.3Supported Yes
PHP 8.2Security-Fixes Only Yes
PHP 8.1Security-Fixes Only 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