Thinkphp has no way to read the file imported by using import ("Common. logAction ", APP_PATH ,'. php '); introduce logAction. php file. This file is a multi-dimensional array with the following structure: $ _ LANG ['log _ action'] ['add'] & nbsp thinkphp file imported with import. it cannot be read.
I use import ("Common. logAction", APP_PATH, '. php') in a function to introduce the logAction. php file. This file is a multidimensional array with the following structure:
$ _ LANG ['log _ action'] ['add'] = 'add ';
$ _ LANG ['log _ action'] ['delete'] = 'delete ';
$ _ LANG ['log _ action'] ['edit'] = 'edit ';
$ _ LANG ['log _ action'] ['import'] = 'import ';
$ _ LANG ['log _ action'] ['sheng'] = 'generation ';
$ _ LANG ['log _ action'] ['print '] = 'print ';
$ _ LANG ['log _ action'] ['General _ ruku '] = 'regular warehouse receiving ';
$ _ LANG ['log _ action'] ['sale _ chuku '] = 'sale warehouse output ';
$ _ LANG ['log _ action'] ['check'] = 'review ';
$ _ LANG ['log _ action'] ['uncheck'] = 'cancel review ';
$ _ LANG ['log _ action'] ['batch _ check'] = 'batch Review ';
However, I cannot read the variable value of the file introduced in the function.
Function admin_log ($ sn = '', $ action, $ content)
{
// Log operations and actions
Import ("Common. logAction", APP_PATH, '. php ');
Echo $ GLOBALS ['_ LANG'] ['log _ action'] [$ action]; exit;
}
Please give me some suggestions...
------ Solution --------------------
Browsed the thinkphp code.
Import is a function, where require_cache is called to load files.
The file is loaded in require_cache: require $ filename;
Therefore, except for the class definition, other data declarations become private variables in the require_cache function.
Unless you declare it a global variable in the loaded file
------ Solution --------------------
Reference:
Yes, it is from the configuration file. I just defined global $ _ LANG; in the introduced file.
But I would like to ask, if there are too many global variable definitions, will it affect?
Will there be too many global variable definitions?
No, but do not conflict with each other.
The configuration file should be configured in the way agreed by TP, and it will be automatically loaded