What are the potential drawbacks of using display() function in Smarty for output?

The potential drawback of using the display() function in Smarty for output is that it directly outputs the content to the browser, making it difficult to capture or manipulate the output before it is sent. To solve this issue, you can use the fetch() function instead, which retrieves the template output as a string that can be stored in a variable for further processing.

// Using fetch() function in Smarty to retrieve template output as a string
$output = $smarty->fetch('template.tpl');

// Manipulate or store the output as needed
echo $output;