Executes a command.
shell_exec() executes a command in a shell and returns the output as a string. The command can also simply be placed within back-ticks (``).
<?php
$output = shell_exec("env");
print "<pre>$output</pre>";
?> TERM=xterm
PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/X11R6/bin
_=/bin/env
PWD=/var/www/html/samples
LANG=en_US.UTF-8
SHLVL=2shell_exec() is used to list its environment variables.
<?php
$output =`ps`;
print "<pre>$output</pre>";
?> PID TTY TIME CMD
2379 ? 00:00:00 httpd
2380 ? 00:00:01 httpd
2381 ? 00:00:00 httpd
2382 ? 00:00:00 httpd
2383 ? 00:00:00 httpd
2384 ? 00:00:01 httpd
2385 ? 00:00:00 httpd
2386 ? 00:00:00 httpd
15938 ? 00:00:00 ps ps and back-ticks are used to print the running processes of the server user.