Introduction to the L method of ThinkPHP

Source: Internet
Author: User

The L method of thinkPHP is used to set and obtain the current language definition when multiple languages are enabled.
The call format is L ('language variable '[, 'language value']).

1. Set language Variables

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

L ('lang _ var', 'language defination ');

The language definition is case insensitive, so the following is equivalent:

L ('lang _ var', 'language defination ');

However, we recommend that you define language variables in uppercase.

L The method supports batch setting of language variables, for example, $ lang ['lang _ var1'] = 'language definition 1 '; $ lang ['lang _ var2'] = 'language definition 2'; $ lang ['lang _ var3'] = 'language definition 3'; L ($ lang );

Set the lang_var1 lang_var2 and lang_var3 language variables.

2. Get language Variables

$ LangVar = L ('lang _ var ');

Or:

$ LangVar = L ('lang _ var ');

If the parameter is blank, it indicates obtaining all the language variables defined currently (including in the language definition file ):

$ Lang = L ();

Or we can use it in the template.

{$ Think. lang. lang_var}

Output language definition.

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.