Thinkphp's L method use introduction _php instance

Source: Internet
Author: User

The thinkphp L method is used to set and get the current language definition when multi-language is enabled.
Its invocation format is: L (' language variable ' [, ' language value '])

1. Set Language variables

In addition to using language packs to define language variables, we can use the L method to dynamically set language variables, such as:

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

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

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

However, for the sake of specification, we recommend unifying uppercase definition language variables.

The L method supports the 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);

Indicates that 3 language variables Lang_var1 lang_var2 and LANG_VAR3 are set at the same time.

2. Get language variables

$langVar = L (' Lang_var ');

Or:

$langVar = L (' Lang_var ');

If the argument is empty, it means getting all the currently defined language variables, including those in the language definition file:

$lang = L ();

Or we can use it in a template.

{$Think. Lang.lang_var}

To output the 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.