PHP/Utility Function/exec

Материал из Web эксперт
Перейти к: навигация, поиск

Executing External Applications Using exec()

 
<?php
        exec("ls /foo/", $output, $return_val);
        echo "Exit code of: $return_val\n";
?>



string exec ( string command [, array &output [, int &return_val]] ) runs an external program

 
print exec("uptime");



Using exec() to Produce a Directory Listing

 
<html>
<head>
<title>Using exec() to Produce a Directory Listing</title>
</head>
<body>
<div>
<?php
exec( "ls -al .", $output, $return );
print "<p>Returned: $return</p>";
foreach ( $output as $file ) {
  print "$file<br />";
}
?>
</div>
</body>
</html>