企业🤖AI Agent构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
``` // 1.引入SMarty include 'libs/Smarty.class.php'; // 2.实例化Smarty $smarty = new Smarty; $smarty->template_dir = 'view'; $smarty->config_dir = 'config'; // 3.获取url的语言参数 $lang = isset($_GET['lang']) ? $_GET['lang'] : 'cn'; $smarty->assign('lang', $lang); // 4.编译并输出模板 $smarty->display('3.html'); ``` ``` <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Document</title> </head> <body> {config_load file="lang.conf" section="$lang"} <table> <tr> <th>{#username#}</th> <th><input type="text"></th> </tr> <tr> <th>{#pass#}</th> <th><input type="text"></th> </tr> <tr> <th colspan="2"><input type="submit" value="{#submit#}"></th> </tr> <tr> <th colspan="2"> <a href="?lang=en">English</a> <a href="?lang=cn">中文</a> </th> </tr> </table> </body> </html> ``` config/lang.cof ``` [en] username="account" pass="password" submit="submit" [cn] username="账户名" pass="密码" submit="提交" ```