Thinkphp cannot read the imported files.

Source: Internet
Author: User
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

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.