Question 1: What is the role of {code...} in the file {code...} of a project ?, Why should I convert $ lang into json format and parse it into a php variable? Isn't that an alternative? Question 2: How do I understand the four sentences {code? My understanding is that the first parameter of assign... is the file of a project.
Sqlite (); $ tLCount = $ tSqlite-> getRow ("select count (0) c FROM sqlite_master where type = 'table' and name = 'Lang '"); $ tLang = array (); if (! Empty ($ tLCount ['c']) {$ tLang = $ tSqlite-> getRow ($ tSql = 'select * from lang ');} $ tLang = empty ($ tLang ['Lang '])? 'Cn': $ tLang ['Lang ']; include realpath (dirname (_ FILE __). '.. /.. /.. /lang /'. $ tLang. '/common. php '); $ lang = json_encode ($ lang); $ lang = json_decode ($ lang); $ this-> assign ('Lang', $ lang ); $ this-> assign ('L', $ tLang); $ this-> l = $ tLang; $ this-> lang = $ lang; // (1 & $ this-> _ auth) & $ this-> _ session (); // (1 <$ this-> _ auth) & $ this-> _ role (); $ tSqlite-> close ();}
Question 1:
$lang = json_encode($lang); $lang = json_decode($lang);
What are the functions of these two sentences ?, Why should I convert $ lang into json format and parse it into a php variable? Isn't that an alternative?
Question 2:
$this->assign('lang' , $lang); $this->assign('l' , $tLang); $this->l = $tLang; $this->lang = $lang;
How can we understand these four sentences?
In my understanding, the first parameter of assign is the variable name, followed by its variable value. However
'$ This-> l = $ tLang;' doesn't it mean to assign '$ tLang' to '$ this''s 'L' attribute? Are these four statements repeated?
Reply content:
Files of a project
Sqlite (); $ tLCount = $ tSqlite-> getRow ("select count (0) c FROM sqlite_master where type = 'table' and name = 'Lang '"); $ tLang = array (); if (! Empty ($ tLCount ['c']) {$ tLang = $ tSqlite-> getRow ($ tSql = 'select * from lang ');} $ tLang = empty ($ tLang ['Lang '])? 'Cn': $ tLang ['Lang ']; include realpath (dirname (_ FILE __). '.. /.. /.. /lang /'. $ tLang. '/common. php '); $ lang = json_encode ($ lang); $ lang = json_decode ($ lang); $ this-> assign ('Lang', $ lang ); $ this-> assign ('L', $ tLang); $ this-> l = $ tLang; $ this-> lang = $ lang; // (1 & $ this-> _ auth) & $ this-> _ session (); // (1 <$ this-> _ auth) & $ this-> _ role (); $ tSqlite-> close ();}
Question 1:
$lang = json_encode($lang); $lang = json_decode($lang);
What are the functions of these two sentences ?, Why should I convert $ lang into json format and parse it into a php variable? Isn't that an alternative?
Question 2:
$this->assign('lang' , $lang); $this->assign('l' , $tLang); $this->l = $tLang; $this->lang = $lang;
How can we understand these four sentences?
In my understanding, the first parameter of assign is the variable name, followed by its variable value. However
'$ This-> l = $ tLang;' doesn't it mean to assign '$ tLang' to '$ this''s 'L' attribute? Are these four statements repeated?
Let's not talk about code writing ..
The first problem is to convert an array into an object.
The second problem is that assign registers Template variables and can be directly used in the view.$lang
. So it is different.
Question 1: here$lang
The variable does not know where to come .... Howeverjson_encode()
,json_decode()
Data type conversion can be performed for writing. If$lang
Is an array, which is converted to an object after the two sentences are executed.
Question 2: I am not very clear ..
Problem 1: converting $ lang variable into object. $ lang is mostly introduced by include. In the template engine, the formats of arrays and objects are different. It may be that the author used it easily, so it turned.
Problem 2: transfer $ lang and $ tLang to the page for convenient page calling. $ This-> l and $ this-> lang are used to save them in the current class for self-or external calls. When we new this class every time, this class will pass two variables to the page, and assign the variable value to the attributes of the current class.