thinkphp function: L method

Source: Internet
Author: User

The L method is used to enable multiple languages, setting and getting the current language definition.
Call format:L (' language variable ' [, ' language value '])
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:

    1. L(‘LANG_VAR‘,‘语言定义‘);

复制代码

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

    1. L(‘lang_var‘,‘语言定义‘);

复制代码

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:

    1. $lang[‘lang_var1‘] = ‘语言定义1‘;
    2. $lang[‘lang_var2‘] = ‘语言定义2‘;
    3. $lang[‘lang_var3‘] = ‘语言定义3‘;
    4. L($lang);

复制代码

Represents the simultaneous setting of 3 language variables Lang_var1 lang_var2 and LANG_VAR3.
[-more-]
Get language variables

    1. $langVar = L(‘LANG_VAR‘);

复制代码

Or:

    1. $langVar = L(‘lang_var‘);

复制代码

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

    1. $lang = L();

复制代码

Or we can use it in a template.

    1. {$Think.lang.lang_var}

复制代码

To output the language definition.

thinkphp function: L method

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.