PHP » I/O » exec()

Syntax:
string exec(string command, array output, int return_value)
command
Command to be executed.
output
Array for the output of the command.
return_value
Integer for the return value of the command.

Executes a command.

This function executes a command in a shell. The optional output parameter is used to return the output of the command to the script. Many commands and programs use their return value to indicate whether they succeeded or failed. This value can be returned through the option return_value. exec() returns the last line of output.

Examples

Code:
<?php

exec("ls upload", $output);
foreach ($output as $line) {
   print "$line<br>";
}

?>
Output:
code.php
log.txt
Explanation:

exec() is used to list the contents of a directory.

See Also: