網站開發基本教學
  • Introduction
  • 基本元素
  • Nginx (伺服器)
    • Config 基本配置
    • Regular Expression 正規化
  • Codeigniter (程式語言框架)
    • Config
    • Controller
    • View
    • Model
      • Question
    • Helper
    • MVC
  • MySQL
Powered by GitBook
On this page

Was this helpful?

  1. Codeigniter (程式語言框架)

Helper

PreviousQuestionNextMVC

Last updated 5 years ago

Was this helpful?

CodeIgniter 預設並不會載入補助函數,所以要使用補助函數時,第一步就是要載入它。一旦載入後,它就可在你的 控制器(controller) 與 檢視(views) 中全域使用。

系統會先從application/helpers尋找,如果這個目錄不存在或是檔案找不到,它才到全域的system/helpers目錄尋找。

載入輔助函數

如何載入?

$this->load->helper('name');

例如,要載入 URL 補助函數 檔案,而他的檔名叫做 url_helper.php ,那你要這樣做:

$this->load->helper('url');