Calling external commands in PHP can be implemented using EXEC and system:
System ()
Prototype: string system (String command [, int return_var])
The system () function is similar in other languages, it executes the given command, outputting and returning the result. The second parameter is optional and is used to get the status code after the command executes.
return results
Successfully returned 0,
Failure (Command not present, etc.) returns a value other than 0
EXEC ()
Prototype: string exec (String command [, string array [, int return_var]])
The exec () function, like system (), also executes the given command, but does not output the result, but instead returns the last line of the result. Although it returns only the last line of the command result, the second parameter array gives the complete result by appending the result line to the end of the array. So if the array is not empty, it is best to clear it with unset () before calling it. The third parameter can be used to obtain the status code of the command execution only if the second parameter is specified.
Example:
EXEC ("/bin/ls-l");
EXEC ("/bin/ls-l", $res);
EXEC ("/bin/ls-l", $res, $RC);
Php:exec and System differences