How can the syntax for concatenating variables and strings be optimized in PHP code?

When concatenating variables and strings in PHP, it is more efficient to use double quotes to enclose the entire string and directly inject the variables using curly braces. This method eliminates the need for multiple concatenation operators and makes the code cleaner and easier to read.

// Inefficient way
$name = "John";
$age = 25;
$message = "Hello, " . $name . "! You are " . $age . " years old.";

// Optimized way
$name = "John";
$age = 25;
$message = "Hello, {$name}! You are {$age} years old.";