What is the recommended method in PHP to execute shell commands for retrieving server information?

When retrieving server information using shell commands in PHP, it is recommended to use the `shell_exec()` function. This function allows you to execute shell commands and capture their output. By using `shell_exec()`, you can easily retrieve server information such as system uptime, disk space, or CPU usage.

// Example of using shell_exec to retrieve server uptime
$uptime = shell_exec('uptime');
echo $uptime;