In addition to the 3 you mentioned, there is still passthru
and the system
for path execution.
pcntl_exec
Creates a separate process from the main process with the executed command, yet allows to set arguments and other settings such as which user should perform this process (only if you have as root)it is developed for UNIX systems and cannot be used on webservers, only in php running via command line (CLI). It is very useful if you are developing an application that needs to manage workspaces and to which user delegate the process. The detail is that this function is part of the PCNTL extension: http://php.net/manual/en/book.pcntl.php
exec
Only returns the last line generated by the output of the specified program execution.
shell_exec
Returns all the output of the command when it has finished running.
system
Runs immediately displaying output, is used to display text.
passthru
Also returns output immediately but is used to display binary data. passthru
displays the "raw data" directly to the browser.
With both commands exec
andshell_exec
it is possible to capture the output(or output), while the system
and the passthru
will not let you customize and display output immediately.
The pcntl_exec
made it necessary when we need to create a block of code that runs asynchronously to the main request, compatible only when php is running in fast-cgi or php-fpm, apache_handler will not work. It allows you to make a "branch" where your code follows 2 paths based on an if, one within the "child" process and another in the "Father" process".
Where is @Bacco when you need it!!!
– StillBuggin