_php tutorials for global variables, local variables in scriptcase

Source: Internet
Author: User
In the case of a set of applications, it is sometimes necessary to use global variables, such as: After the successful login to save the user name, and then in each page can be used (for example, using the user name to the user can see the data filtered). At this point, you need to use global variables.


The global variables of the scriptcase are marked as: [VarName].


For example, at the time of login, the user name can be saved to [Usr_login] after verification pass, so long as it can be used in the application inside the system, whether it is in the code or in the configuration function.


On a list, we may want to display only the current user's data, and its SQL statement can be configured as:


SELECT filename1, fieldname2 from table1 WHERE login= ' [Usr_login] '


The system reads the global variable and prompts the user to log back in if the login fails.


If you define a variable that is used in the current function, you can use the $varname directly.


For a field, you can use {fieldname} to access it. For example, we want to encrypt the user-set password with MD5 and save it to the database, which can be written in this form:

{Password} = MD5 ({password});


Curly braces There is also an application of a multi-lingual translation, as long as the definition of language tags, can be used directly in the code, such as:


{ErrorMessage} = {Lang_message_inserterror};


You can set the characters for different languages in the language Settings-regional language so that the system can support multiple languages.

http://www.bkjia.com/PHPjc/477431.html www.bkjia.com true http://www.bkjia.com/PHPjc/477431.html techarticle when doing a set of applications, it is sometimes necessary to use global variables, such as: After the successful login to save the user name, and then in each page can be used (for example, the use of ...

  • 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.