What are the potential security risks of using shell_exec in PHP scripts?

Using `shell_exec` in PHP scripts can pose security risks such as command injection attacks if user input is not properly sanitized. To mitigate this risk, always validate and sanitize user input before passing it to `shell_exec`, and consider using safer alternatives like `exec` with arguments passed as an array.

// Example of using exec with arguments passed as an array to prevent command injection
$user_input = $_POST['user_input'];
$command = ['/path/to/executable', $user_input];
$output = [];
exec(escapeshellcmd(implode(' ', $command)), $output);