8 Articles about php static local variables

Source: Internet
Author: User
Local variables can be divided into dynamic and static storage types. Local variables in the function. if they are not specifically declared as static storage classes, they are dynamically allocated by default. The internal dynamic variables are automatically released after the function call is completed. If you want to keep the internal variables in the memory after the function is executed, you should use static variables. After the function is executed, the static variables will not disappear, but will be shared among all calls to the function. that is, when the function is executed again, the static variables will continue the operation for the previous consecutive result, and only in the script execution period... local variables can be divided into dynamic and static storage types. Local variables in the function. if they are not specifically declared as static storage classes, they are dynamically allocated by default. The internal dynamic variables are automatically released after the function call is completed. If you want to keep the internal variables in the memory after the function is executed, you should use static variables. After the function is executed, the static variables will not disappear, but will be shared among all calls to the function. that is, when the function is executed again, the static variables will continue the operation for the previous consecutive result, the function is initialized only when the function is called for the first time during script execution. To declare a function variable as static, use the keyword static. We have introduced the range of php variables to local variables and the range of php variables to global variables. Static variables can be applied in any place where they can be applied. Once the application is successful, it will no longer accept other applications. Static variables do not mean that they cannot change the value, and the amount of values that cannot be changed is a constant. Its value is variable, and it will keep the latest value. It is static because it does not change with the function call and exit. That is, the last call

1. differences between static local variables and static global variables

Introduction: local variables can be divided into dynamic and static storage types. Local variables in the function. if they are not specifically declared as static storage classes, they are dynamically allocated by default.

2. PHP source code learning-thread security

Introduction: in terms of scope, the C language can define four different variables: global variables, static global variables, local variables, and static local variables.

3. static local variables of php

Introduction: This article mainly introduces static local variables of php. For more information about PHP tutorials, see.

4. PHP static local static variables and global static variables summary_php tutorial

Summary: PHP static local static variables and global static variables. Static local variable features: 1. it will not change with the function call and exit. However, although the variable still exists, it cannot be used. If you call the function to define it again

5. view the features of C, C ++, C #, Java, and PHP through static local variables

Introduction: The characteristics of C, C ++, C #, Java, and PHP can be viewed through static local variables.

6. Summary of PHP static local static variables and global static variables

Summary: PHP static local static variables and global static variables. Static local variable features: 1. it will not change with the function call and exit. However, although the variable still exists, it cannot be used. If you call the function to define it again

7. PHP static local variables and static global variables

Introduction: 1. it will not change with the function call and exit. However, although the variable still exists, it cannot be used. If you call the function that defines it again, it can continue to be used, and save the value left after the previous call 2. static local variables are initialized only once. static attributes can only be initialized as one character value or a constant and cannot be used.

8. PHP static local static variables and global static variables

Summary: The reason for using static local variables is that they cannot be used externally, but their values are retained after they are not used. Although global variables can be used to implement the same functions, they often cause exceptions.

The above are the details recommended by the eight articles on php static local variables. For more information, see other related articles in the first PHP community!

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.