Public functions in CodeIgniter cannot be appended and can be implemented through helper auxiliary functions.
Create common_helper.php files, define the required public functions, and store them in the Application/helpers directory.
Configure $autoload [' helper '] = Array (' common ') in application/config/autoload.php; Can.
Global variables can also be implemented with the help of helper functions. However, a more appropriate approach might be defined by the configuration class .
CodeIgniter Default has a primary configuration file, located in the application/config/config.php path, which defines a stack of framework-level global configurations, an array called $config.
If you need to add a global configuration item, you can implement it in this file, considering the separation of custom configuration and framework configuration, it is recommended that you create a new file vars.php, and then define the following:
Copy Code code as follows:
/**
* Working Directory Configuration
*/
$config [' src '] [' cache '] = Fcpath. '.. /src/cache ';
$config [' src '] [' modules '] = Fcpath. '.. /src/modules ';
$config [' src '] [' www '] = fcpath. '.. /src/www ';
When used, read from the controller with the following code:
$SRC = $this->config->item (' src ');
$cache = $src [' Cache ']
Or:
Copy Code code as follows:
$SRC = $this->config->item (' cache ', ' src ');
Of course, you need to automatically load this configuration file in application/config/autoload.php.