exec in PHP

Syntax of exec in PHP

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

Example of exec in PHP

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

Output of exec in PHP

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

Leave a Comment