Thinkphp has no way to read the file imported by using import ("Common. logAction ", APP_PATH ,'. php '); introduce logAction. php file, which is a multi-dimensional 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...
Reply to discussion (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
You seem to be using multi-language support
So why not use the built-in multi-language support for ThinkPHP?
I am not using multi-language support. I am just working on a function to record operation logs. the file mentioned above is the action of some operations.
The introduced file is not a class, but a php file that stores arrays.
You just need to include
However, it is better to abide by other people's rules.
Should this file be a configuration file?
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?
When the TP framework is not used, include is used for introduction, and global variables are not declared.
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
Reference babyface008 008 on the 7th floor: Yes, it is from the configuration file. I just defined global $ _ LANG in the file to be introduced.
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
Okay. thank you for reminding me.