Home  >  Article  >  Backend Development  >  Introduction to the use of ThinkPHP's L method_PHP tutorial

Introduction to the use of ThinkPHP's L method_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 10:24:441380browse

thinkPHP’s L method is used to set and get the current language definition when multiple languages ​​are enabled.
The calling format is: L('language variable'[,'language value'])

1. Set language variables

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

L('LANG_VAR','语言定义');

The language definition is not case-sensitive, so the following is also equivalent:

L('LANG_VAR','语言定义');

However, for the sake of standardization, we recommend that you use uppercase letters to define language variables.

L方法支持批量设置语言变量,例如:
$lang['lang_var1'] = '语言定义1';
$lang['lang_var2'] = '语言定义2';
$lang['lang_var3'] = '语言定义3';
L($lang);

means setting three language variables lang_var1 lang_var2 and lang_var3 at the same time.

2. Get language variables

$langVar = L('LANG_VAR');

or:

$langVar = L('lang_var');

If the parameter is empty, it means to obtain all currently defined language variables (including those in the language definition file):

$lang = L();

Or we can also use
in the template

{$Think.lang.lang_var}

to output the language definition.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/825335.htmlTechArticlethinkPHP’s L method is used to set and get the current language definition when multiple languages ​​are enabled. The calling format is: L('Language variable'[,'Language value']) 1. Set the language variable. In addition to using the language...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn