How does the use of a template engine like Smarty impact the overall loading time of a PHP script, and are there alternative solutions that could improve performance?

Using a template engine like Smarty can impact the overall loading time of a PHP script because it adds an additional layer of processing to compile and render the templates. One alternative solution to improve performance is to use PHP's built-in templating system or a lightweight template engine like Twig, which can offer similar functionality with less overhead.

// Example using PHP's built-in templating system
<?php
$templateData = ['title' => 'Hello, World!', 'content' => 'This is a sample content.'];
ob_start();
include 'template.php';
$output = ob_get_clean();
echo $output;
?>

// template.php
<!DOCTYPE html>
<html>
<head>
    <title><?php echo $templateData['title']; ?></title>
</head>
<body>
    <div><?php echo $templateData['content']; ?></div>
</body>
</html>