Php and MySQLWeb development-Book Note 2

Source: Internet
Author: User
: This article mainly introduces "php and MySQLWeb development"-Reading Notes 2. if you are interested in the PHP Tutorial, refer to it. 15 understand the scope
The scope of a variable can control where the variable is visible and available. Different programming languages have different variable scope rules. PHP has simple rules:
1. the variable scope declared in the function starts from the statement that declared them to the end of the function. This is called the function scope. These variables are called local variables.


  GetMessage () ;}$ ob-> g (); // Note: $ ob variable does not have function scope}

2. the variable scope declared outside the function starts from the statement that declared them to the end of the file, rather than inside the function. This is called global scope. These variables are called global variables.
3. Special Super global variables are visible inside and outside the function. For example, _ GET, _ POST, _ FILE.
4 Using require () and include () does not affect the scope. If these two statements are used inside the function, the function scope applies. If it is not within the function, the global scope applies.
5. the keyword global can be used to manually specify that the variables defined or used in a word function have a global scope.
6. you can manually delete a variable by calling unset ($ variable_name. If the variable is deleted, it is not in the scope specified by the parameter.

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.