Home > Backend Development > PHP Tutorial > Global variables and local variables in ScriptCase_PHP tutorial

Global variables and local variables in ScriptCase_PHP tutorial

WBOY
Release: 2016-07-14 10:11:02
Original
1321 people have browsed it

When making an application, sometimes you need to use global variables. For example, after successful login, save the username and then use it in every page (for example, using the username to see what the user can see) filtered data). At this time, global variables need to be used.


The global variable mark of Scriptcase is: [varname].


For example, when logging in, after passing the verification, the user name filled in by the user can be saved in [usr_login], and it can be used in applications in the system in the future, whether in code or in configuration functions.


On a certain list, we may want to display only the current user’s data, then the SQL statement can be configured as:


SELECT filename1, fieldname2 FROM table1 WHERE login='[usr_login]'


The system will read the global variable. If the login fails, the user will be prompted to log in again.


If you are defining a variable used in the current function, you can use $varname directly.


For fields, you can use {fieldname} to access. For example, if we want to encrypt the password set by the user with MD5 and save it to the database, we can write it in the following form:

{password} = md5({password});


Another application of braces is for multi-language translation. As long as the language tag is defined, it can be used directly in the code, such as:


{errormessage} = {lang_message_inserterror};


You can set the characters corresponding to different languages ​​in "Language Settings - Regional Language" so that the system can support multiple languages.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/477431.htmlTechArticleWhen making an application, sometimes you need to use global variables, for example: after successful login, the user Save the name and use it on every page (for example, use...
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