Nginx-php Basics ..

Source: Internet
Author: User
Tags php basics
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$langThe variable does not know where to come .... Howeverjson_encode(),json_decode()Data type conversion can be performed for writing. If$langIs 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.

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.