Are there alternative methods or approaches to running programs or commands from a PHP script, especially in the context of a Raspberry Pi setup?

When running programs or commands from a PHP script on a Raspberry Pi, one alternative method is to use the shell_exec() function. This function allows you to execute shell commands and get the complete output as a string. This can be useful for running system commands or interacting with other programs on the Raspberry Pi.

<?php
$output = shell_exec('ls -l');
echo "<pre>$output</pre>";
?>