Introduction to the use of ThinkPHP's L method_PHP tutorial

WBOY
Release: 2016-07-13 10:24:44
Original
1376 people have browsed it

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','语言定义');
Copy after login

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

L('lang_var','语言定义');
Copy after login

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);

Copy after login

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

2. Get language variables

$langVar = L('LANG_VAR');

Copy after login

or:

$langVar = L('lang_var');
Copy after login

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

$lang = L();
Copy after login

Or we can also use
in the template

{$Think.lang.lang_var}
Copy after login

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...
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template