CI框架中l(wèi)ibraries,helpers,hooks文件夾詳細(xì)說(shuō)明
Jun 13, 2016 am 09:34 AM
1.library文件夾
如果你想擴(kuò)展CI的功能,那么就把你的類(lèi)庫(kù)放在這,注意,這個(gè)文件夾是有class組成的,可以看看如果加載library注意事項(xiàng)!
2.helper文件夾
如果你需要使用一些函數(shù)來(lái)幫你完成一些小功能,那么就把它放著,這里都是過(guò)程式的代碼而不是類(lèi),一般helper是用于view的,
使用方法如下:
復(fù)制代碼 代碼如下:
$this->load->helper('filename')
filename是輔助函數(shù)對(duì)應(yīng)的文件名,不包括_helper.php擴(kuò)展名。文件名應(yīng)該保存為:filename_helper.php,放在helper文件夾下!
3.hooks文件夾
存放你創(chuàng)建的鉤子。鉤子是 用來(lái)裝載其它文件的控制方法,不能被控制器等調(diào)用,是系統(tǒng)自動(dòng)調(diào)用的。當(dāng) CodeIgniter
運(yùn)行后,它會(huì)產(chǎn)生出一個(gè)特殊的進(jìn)程。
當(dāng)然,您可以自定義一些動(dòng)作來(lái)替代程序運(yùn)行過(guò)程中的某些階段。例如,您可以在控制器剛剛載入前或剛剛載入后來(lái)運(yùn)行特定的腳本,或者在其他時(shí)刻來(lái)觸發(fā)您的腳本。
CI的七個(gè)掛載點(diǎn):
pre_system
系統(tǒng)執(zhí)行的早期調(diào)用.僅僅在benchmark 和 hooks 類(lèi) 加載完畢的時(shí)候. 沒(méi)有執(zhí)行路由或者其它的過(guò)程.
pre_controller
在調(diào)用你的任何控制器之前調(diào)用.此時(shí)所用的基礎(chǔ)類(lèi),路由選擇和安全性檢查都已完成.
post_controller_constructor
在你的控制器實(shí)例化之后,任何方法調(diào)用之前調(diào)用.
post_controller
在你的控制器完全運(yùn)行之后調(diào)用.
display_override
覆蓋_display()函數(shù), 用來(lái)在系統(tǒng)執(zhí)行末尾向web瀏覽器發(fā)送最終頁(yè)面.這允許你用自己的方法來(lái)顯示.注意,你需要通過(guò)$this->CI =& get_instance()引用 CI 超級(jí)對(duì)象,然后這樣的最終數(shù)據(jù)可以通過(guò)調(diào)用$this->CI->output->get_output()來(lái)獲得。
cache_override
可以讓你調(diào)用自己的函數(shù)來(lái)取代output類(lèi)中的_display_cache()函數(shù).這可以讓你使用自己的緩存顯示方法
post_system
在最終著色頁(yè)面發(fā)送到瀏覽器之后,瀏覽器接收完最終數(shù)據(jù)的系統(tǒng)執(zhí)行末尾調(diào)用?
關(guān)于鉤子的使用,手冊(cè)上有詳細(xì)的使用說(shuō)明,截圖如下:

Hot AI Tools

Undress AI Tool
Undress images for free

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

With the development of network technology, PHP has become one of the important tools for Web development. One of the popular PHP frameworks - CodeIgniter (hereinafter referred to as CI) has also received more and more attention and use. Today, we will take a look at how to use the CI framework. 1. Install the CI framework First, we need to download the CI framework and install it. Download the latest version of the CI framework compressed package from CI's official website (https://codeigniter.com/). After the download is complete, unzip

PHP is a popular programming language that is widely used in web development. The CI (CodeIgniter) framework is one of the most popular frameworks in PHP. It provides a complete set of ready-made tools and function libraries, as well as some popular design patterns, allowing developers to develop Web applications more efficiently. This article will introduce the basic steps and methods of developing PHP applications using the CI framework. Understand the basic concepts and structures of the CI framework. Before using the CI framework, we need to understand some basic concepts and structures. Down

PHP is a widely used server-side scripting language, and CodeIgniter4 (CI4) is a popular PHP framework that provides a fast and excellent way to build web applications. In this article, we will get you started using the CI4 framework to develop outstanding web applications by walking you through how to use it. 1. Download and install CI4 First, you need to download it from the official website (https://codeigniter.com/downloa

With the development of the Internet and its continuous integration into people's lives, the development of network applications has become more and more important. As a well-known programming language, PHP has become one of the preferred languages ??for developing Internet applications. Developers can use numerous PHP frameworks to simplify the development process, one of the most popular is the CodeIgniter (CI) framework. CI is a powerful PHP web application framework. It has the characteristics of lightweight, easy to use, optimized performance, etc., allowing developers to quickly build

The steps to introduce CSS styles in the CI framework are as follows: 1. Prepare CSS files; 2. Store the CSS files in the appropriate location of the CI framework project; 3. In the pages that need to use CSS styles, introduce CSS through the HTML <link> tag File; 4. Use the CSS class or ID name in the HTML element to apply the corresponding style.

Tutorial: Detailed steps for introducing CSS styles in the CI framework, specific code examples are required Introduction: Style is a crucial part of developing web applications. Use CSS (Cascading Style Sheets) to beautify web pages and provide a better user experience. When developing using the CodeIgniter (CI) framework, how to correctly introduce CSS styles is particularly important. This article will introduce the detailed steps of introducing CSS styles in the CI framework and provide you with specific code examples. Step 1: Create CSS File First,

The steps for introducing CSS styles in the CI framework require specific code examples. The CI (CodeIgniter) framework is a popular PHP development framework that is widely used to build efficient web applications. When developing web applications, a beautiful user interface is an important consideration. Using CSS styles can optimize and personalize the web application interface, giving users a better experience. In a CI framework, introducing CSS styles usually requires the following steps, accompanied by specific code examples. step 1:

PHP is a very popular web development language, and CodeIgniter (CI) is a very popular PHP framework. CodeIgniter provides many useful functions and features, bringing great convenience to developers. In this article, we will explore how to use the CI6 framework. Installing CI6 Before you can start using CI6, you must first complete the installation process. You need to first download the CI6 compressed package from the CodeIgniter official website. Then, unzip this file and place it in
