thinkphp file imported with import, no way to read

Source: Internet
Author: User
I use Import ("Common.logaction", App_path, '. php ') within a function, introducing the logaction.php file, which is a multidimensional array with the following structure:
$_lang[' log_action ' [' add '] = ' add ';
$_lang[' log_action ' [' remove '] = ' delete ';
$_lang[' log_action ' [' edit '] = ' editor ';
$_lang[' log_action ' [' import '] = ' importing ';
$_lang[' log_action ' [' sheng '] = ' generate ';
$_lang[' log_action ' [' print '] = ' printing ';
$_lang[' log_action ' [' general_ruku '] = ' conventional warehousing ';
$_lang[' log_action ' [' sell_chuku '] = ' sales out of the library ';
$_lang[' log_action ' [' check '] = ' audit ';
$_lang[' log_action ' [' uncheck '] = ' Cancel audit ';
$_lang[' log_action ' [' batch_check '] = ' batch audit ';

But I can't read the value of the variable that introduced that file in my function.
function Admin_log ($sn = ", $action, $content)
{
Log operations, actions
Import ("Common.logaction", App_path, '. php ');
echo $GLOBALS [' _lang '] [' log_action '] [$action];exit;


}

Would you please give me some advice?


Reply to discussion (solution)

Browse the code for thinkphp
Import is a function in which the Require_cache load file is called
And the file is loaded in Require_cache: Require $filename;
Therefore, in addition to the class definition, other data declarations become private variables in the function Require_cache
Unless you declare it as a global variable in the file being loaded

You seem to be doing more language support
So why not use thinkphp built-in multi-language support?

I'm not using multi-lingual support, I'm just doing a recording of the operation log function, mentioned above to introduce the file, is the action of some actions.

And the introduction of the file is not a class, is a php file, the storage array.

You just include it.
But it's better to obey the rules of the family.
Do you think this file is a configuration file?

Right, that's the config file, I just defined the global $_lang in the file that I was introduced to.
But I would like to ask, if the global variable definition too much will have an impact?

When the TP framework was not used, it was introduced with include without declaring global variables

Right, that's the config file, I just defined the global $_lang in the file that I was introduced to.
But I would like to ask, if the global variable definition too much will have an impact? Does a global variable definition have too many implications?
No, I just need to be careful not to clash.

The configuration file should be done in the form of TP conventions, and he will automatically load

Reference to the 7 floor babyface201008 reply: Right, is the configuration file, I just in the introduction of the file defined by the global $_lang;
But I would like to ask, if the global variable definition too much will have an impact? Does a global variable definition have too many implications?
No, I just need to be careful not to clash.

The configuration file should be done in the form of TP conventions, and he will automatically load

OK, thanks for the reminder.

  • 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.