exec in PHP

Syntax of exec in PHP

string exec(string command[, array output[, int return]])

Example of exec in PHP

// outputs the username that owns the running php/httpd process
// (on a system with the "whoami" executable in the path)
exec('whoami', $output, $retval);
echo "Returned with status $retval and output:\n";

Output of exec in PHP

Returned with status 0 and output:
    [0] => cmb

Leave a Comment