What are some common reasons for encountering a loop or "Ladeschleife" when using shell_exec in PHP?

When using shell_exec in PHP, a common reason for encountering a loop or "Ladeschleife" is when the command being executed within shell_exec itself triggers a loop or infinite recursion. To solve this issue, you should carefully review the command being passed to shell_exec and ensure that it does not contain any logic that could potentially lead to a loop.

$output = shell_exec('ls -l');
echo $output;