The shell_exec() function is an inbuilt function in PHP which is used to execute the commands via shell and return the complete output as a string. The shell_exec is an alias for the backtick operator, for those used to *nix. If the command fails return NULL and the values are not reliable for error checking.
string shell_exec( $cmd )
Parameters: This function accepts single parameter $cmd which is used to hold the command that will be executed.
Return Value: This function returns the executed command or NULL if an error occurred.
Note: This function is disabled when PHP is running in safe mode.
gfg.php index.html geeks.php
The exec() function is an inbuilt function in PHP which is used to execute an external program and returns the last line of the output. It also returns NULL if no command run properly.
string exec( $command, $output, $return_var )
Parameters: This function accepts three parameters as mentioned above and described below:
- $command: This parameter is used to hold the command which will be executed.
- $output: This parameter is used to specify the array which will be filled with every line of output from the command.
- $return_var: The $return_var parameter is present along with the output argument, then it returns the status of the executed command will be written to this variable.
Return Value: This function returns the executed command, be sure to set and use the output parameter.
- D3.js | d3.hsl() Function
- p5.js | box() Function
- PHP | pos() Function
- p5.js | hex() function
- p5.js | arc() Function
- p5.js | cos() function
- PHP | pow( ) Function
- PHP | Ds\Map map() Function
- p5.js | red() function
- PHP | Ds\Map last() Function
- PHP | key() Function
- PHP | min( ) Function
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.