php-pcntlHow to use the PCNTL_EXEC function in PHP?
The PCNTL_EXEC function in PHP is used to execute a program in the background. It takes the program name and its arguments as parameters.
Example
<?php
$program = '/usr/bin/php';
$args = array('-v');
pcntl_exec($program, $args);
Output example
PHP 7.2.10 (cli) (built: Sep 10 2018 13:45:04) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
Code explanation
$program
: This is a string containing the path to the program to be executed.$args
: This is an array containing the arguments to be passed to the program.pcntl_exec()
: This is the function that executes the program. It takes two parameters, the program name and its arguments.
Helpful links
More of Php Pcntl
- How to install PCNTL for PHP in Debian?
- How to use PCNTL alarm in PHP?
- How to use pcntl_wifexited in PHP?
- How to use pcntl_wexitstatus in PHP?
- How to use pcntl_signal in PHP?
- How to check if PCNTL is enabled in PHP?
- How to use pcntl_wait in PHP?
- How to use pcntl_waitpid in PHP?
- How to get the process ID with PHP PCNTL?
- How to use pcntl_fork in PHP?
See more codes...