PHP’s exec Command
Some things to note about PHP’s shell execution.
So the first thing to note is that if you do not include the optional array, which is a pass by reference variable, that the command will not wait until it’s done executing before moving on in the PHP code. If you do include the array, it will put the output of the command into the array, unless in your command you route the output to another spot, like a text file.
Also note that if you have multiple exec’s in the same PHP script, it will append the results onto the array you pass it. You need to physically get reset the array to empty before you call your exec.
exec is a great way to do operating system calls from PHP. Alot of times there are easier ways to do things with native OS functions than to use the PHP scripts.