shell_exec
- Execute command via shell and return the complete output as a string. Output is output in terminal.
So this:
<?php
$output = shell_exec('ls -lart');
echo "<pre>$output</pre>";
?>
Will return ls -lart of your directory.
If you do the same with gedit
output would be just error messages and warnings because gedit returns text into GUI not into terminal.
If you want to get some text with this command you can do it with cat
<?php
$output = shell_exec('cat ' . $filename');
echo "<pre>$output</pre>";
?>
This is how you open and edit file.
<?php
$myfile = fopen("webdictionary.txt", "r") or die("Unable to open file!");
echo fread($myfile,filesize("webdictionary.txt"));
fclose($myfile);
?>
PHP References