connect_error) {
die('無法連上資料庫 (' . $db->connect_errno . ') '
. $db->connect_error);
}
#設定資料庫語系
$db->set_charset("utf8");
```
三、smarty.php
```
left_delimiter = "<{"; //指定左標籤
#指定左標籤定義符
$smarty->right_delimiter = "}>"; //指定右標籤
#指定模版存放目錄
$smarty->template_dir = _WEB_PATH . '/templates/';
#指定編譯文件存放目錄
$smarty->compile_dir = _WEB_PATH . '/templates_c/';
#指定配置文件存放目錄
$smarty->config_dir = _WEB_PATH . '/configs/';
#暫存路徑
$smarty->cache_dir = _WEB_PATH . '/cache/';
#開啟調試控制台,輸出變數
//$smarty->debugging = true;
#開啟緩存
//$smarty->caching = true;
#設定緩存時間,詳見 https://www.smarty.net/docs/zh_CN/caching.tpl
//$smarty->cache_lifetime = 120;
#定義模板URL
$smarty->assign("xoImgUrl", _WEB_URL . '/templates/');
$smarty->assign("xoAppUrl", _WEB_URL."/");
```
四、function.php
```
assign("WEB", $WEB);
$smarty->assign("op", $op);
/*---- 程式結尾-----*/
$smarty->display('theme.tpl');
/*---- 函數區-----*/
function xxx(){
global $smarty;
}
function yyy(){
global $smarty;
}
function op_list(){
global $smarty;
}
```
user.php
```
assign("WEB", $WEB);
$smarty->assign("op", $op);
/*---- 程式結尾-----*/
$smarty->display('user.tpl');
/*---- 函數區-----*/
function op_form(){
global $smarty;
}
function yyy(){
global $smarty;
}
function op_list(){
global $smarty;
}
```
上課用:
```
"<{$xoImgUrl}>vendor/
```
```
"<{$xoImgUrl}>js/
```
```
"<{$xoImgUrl}>css/
```
```
"<{$xoImgUrl}>img/
```
Git
[https://www.ugm.com.tw/modules/tad\_book3/page.php?tbdsn=1108](https://www.ugm.com.tw/modules/tad_book3/page.php?tbdsn=1108)
web11