What is the correct syntax for concatenating variables in a shell command within a PHP script?

When concatenating variables in a shell command within a PHP script, you need to enclose the variables in double quotes within the shell command. This allows PHP to substitute the variable values within the command. Additionally, you can use curly braces around the variable name to make it clear where the variable name ends.

// Concatenating variables in a shell command within a PHP script
$var1 = "Hello";
$var2 = "World";

// Correct syntax for concatenating variables in a shell command
$command = "echo \"${var1} ${var2}\"";

// Execute the shell command
$output = shell_exec($command);

// Output the result
echo $output;