| Attribute Name | Type | Required | Default | Description |
|---|---|---|---|---|
| file | string | Yes | n/a | the file, http or ftp site to fetch |
| assign | string | No | n/a | the template variable the output will be assigned to |
fetch is used to fetch files from the local file system, http, or ftp and display the contents. If the file name begins with "http://", the web site page will be fetched and displayed. If the file name begins with "ftp://", the file will be fetched from the ftp server and displayed. For local files, the full system file path must be given, or a path relative to the executed php script.
fetch 的功能是從本地端檔案系統中,http,或 ftp 協定中取得與展示檔案。如果檔 案的名稱開頭是 "http://",則網頁將會被取得與展示,如果檔案的名稱開頭是 "ftp://",則 檔案會從 ftp 伺服器取出與展示。對本地端檔案而言,必須提供檔案的完整路徑,或是相對於 php 程式檔的相對路徑。
If you supply the special "assign" attribute, the output of the fetch function will be assigned to this template variable instead of being output to the template. (new in Smarty 1.5.0)
如果你有使用 "assign" 屬性,則 fetch 函式的輸出會被指定給某個樣版變數而不會 直接輸出至樣版(Smarty 1.5.0 的新功能)。
Technical Note: This will not support http redirects, be sure to include a trailing slash on your web page fetches where necessary.
技術提醒: 此函式支援 http 重導,如果要抓取目錄而不是檔案的話,請確定你的網址中有包含最後的 斜線。
Technical Note: If template security is turned on and you are fetching a file from the local file system, this will only allow files from within one of the defined secure directories. ($secure_dir)
技術提醒: 如果樣版的安全機制有開啟且你正從本地端檔案系統取出檔案,則你將只被允許從被定義為 安全的目錄中取得檔案($secure_dir)。