1. Home
  2. Php
  3. Shell exec

This function lets you run a shell command directly from a php file. Output of the command will be returned as a string so it can be displayed too.

#php
/* ls -al returns a list of all folders and files in the directory */
$list_folders = shell_exec('ls -al');

/* Display output */
echo "<pre>$list_folders</pre>";
copy
Full Php cheatsheet