Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

exec

exec() is used to execute a command with the underlying operating system. It is the equivalent of shell_exec() and back-ticks.

exec() has specific arguments to collect both the result of the command, one line per element in an array, and the resulting code. This differs from shell_exec(), which only returns the result, and as a string.

<?php

$dir = exec('ls', $result);
print_r($result);

?>

Documentation

See Also