What are the best practices for formatting output in PHP using printf?

When formatting output in PHP using printf, it is important to use placeholders (%s, %d, %f) to specify where variables should be inserted in the output string. Additionally, you can use formatting options such as precision and padding to control the appearance of the output. It is also recommended to use printf instead of echo for complex output formatting to keep the code more organized and maintainable.

$name = "John";
$age = 30;
$height = 5.8;

printf("Name: %s, Age: %d, Height: %.1f", $name, $age, $height);