//PHP code $data = ['name' => 'John', 'age' => 30]; $smarty->assign_by_ref('data', $data); //Smarty templateName: {$data.name}
Age: {$data.age}
//PHP code $name = 'John'; $smarty->assign_by_ref('name', $name); $smarty->display('template.tpl'); //Smarty template {$name = 'Bob'} //Back in PHP code echo $name;In this example, we assign the `$name` variable to the Smarty template using `assign_by_ref`. In the template, we modify the value of `$name` to 'Bob'. This change is reflected in the original `$name` variable in the PHP code, and we can see the updated value echoed out. Package library: Smarty Template Engine.