Autoload. php automatic loading usage analysis of CodeIgniter configuration, codeigniterautoload_PHP tutorial

Source: Internet
Author: User
Tags codeigniter
CodeIgniter: autoload. php automatic loading usage analysis, codeigniterautoload. Autoload. php automatic loading usage analysis of CodeIgniter configuration. in this article, we analyze the autoload. php automatic loading usage of CodeIgniter configuration. We will share with you the usage analysis of autoload. php automatic loading in CodeIgniter configuration. codeigniterautoload

This article analyzes how to use autoload. php to automatically load CodeIgniter configurations. We will share this with you for your reference. The details are as follows:

CodeIgniter provides the automatic loading function to globally load class libraries, models, configurations, and language packs. it is quite convenient for global functions.

For example, if a global function is written in app_helper.php and needs to be loaded globally, you only need to set autoload. php:
The code is as follows: $ autoload ['helper'] = array ('app ');
Next, you can use all the configurations, such as configuration and model. However, it is convenient to consider the disadvantages of this loading method.

If a project is divided into two parts, such as the foreground and background, is this function required? If there are different business modules in the front and back end, is it required for each module?

If you need it all, it is good to write it here. if you don't need it, it is not recommended to write it here.

Related class libraries and function calls should be loaded as needed

There are many ways to load data. you can load data on a specified page or in a public controller or function. once load is enabled, it can be used globally. My common practice is to ignore this file and manually load global functions.

Let's talk about the CI loading mechanism. The following describes how to load class libraries and functions:

$this->load->library('session');$this->load->model('hello_model');$this->load->helper(array('url', 'array'));$this->load->language(array('user_menu', 'user_tips'));

The loading method is uniform and easy to use, but it is inconvenient to pass parameters during the load class library. When the class library is loaded again, it will not be loaded again, but will be taken out from the saved static array. pay attention to the status of member attributes to Prevent program exceptions due to the existence of values.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.