Thinkphp The L Method usage Introduction _php Tutorial

Source: Internet
Author: User
The thinkphp L method is used to enable multi-language scenarios, setting and getting the current language definition.
Its invocation format is: L (' language variable ' [, ' language value '])

1. Setting Language variables

In addition to using language packs to define language variables, we can dynamically set language variables using the L method, for example:

L (' Lang_var ', ' language definition ');

Language definitions are not case-sensitive, so the following are equivalent:

L (' Lang_var ', ' language definition ');

But for the sake of specification, we recommend using uppercase to define language variables uniformly.

The L method supports batch setting of language variables such as: $lang [' lang_var1 '] = ' language definition 1 '; $lang [' lang_var2 '] = ' language definition 2 '; $lang [' lang_var3 '] = ' language definition 3 '; L ($lang);

Represents the simultaneous setting of 3 language variables Lang_var1 lang_var2 and LANG_VAR3.

2. Get language variables

$langVar = L (' Lang_var ');

Or:

$langVar = L (' Lang_var ');

If the argument is empty, it means getting all of the currently defined language variables (including the language definition file):

$lang = L ();

Or we can use it in a template.

{$Think. Lang.lang_var}

To output the language definition.

http://www.bkjia.com/PHPjc/825335.html www.bkjia.com true http://www.bkjia.com/PHPjc/825335.html techarticle The thinkphp L method is used to enable multi-language scenarios, setting and getting the current language definition. Its invocation format is: L (' language variable ' [, ' language Value ']) 1. Setting language variables in addition to making the term ...

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