set_var('title', 'My Page'); $template->parse('page.tpl'); ?>
set_var(array( 'title' => 'My Page', 'description' => 'This is my page description', 'keywords' => 'php, templates', )); $template->parse('page.tpl'); ?>In this example, we use the set_var function to set multiple variables at once. We pass an array of variables and their values to the function. The template is then parsed with the variables substituted where they are used in the template. Package/library: This code examples are using an external PHP library called PHP Template (or phptal).