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.

/* 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>";
Full Php cheatsheet