The variable scope _php tutorial in PHP Web development

Source: Internet
Author: User
Tags php web development variable scope
1. There is no global static variable in PHP

Done before. NET development, you can use the following methods to cache some data:

View Plaincopy to Clipboardprint?






PGP is an interpreted language, although there are static modifiers, but the meaning is with. NET is completely different.

Even if a variable in the class is declared static, the variable is only valid in the application domain at the current page level.

2. Understanding Variable Scope

Variables declared outside the method body are not accessible within the method body.

Such as:

View Plaincopy to Clipboardprint?























The _displayurl method does not show any results because the variable, the _displayurl, is inaccessible in the method body, and global can be added to the prefix, such as the Displayurl method.

The global variables defined in the method body can be accessed outside the method body:

View Plaincopy to Clipboardprint?

 





?>

You are reading about variable scopes in PHP Web development

    1. PHP Developer: Are you glammp?
    2. 10 section php common function code
    3. The idea and example of PHP implementing file Upload

http://www.bkjia.com/PHPjc/589158.html www.bkjia.com true http://www.bkjia.com/PHPjc/589158.html techarticle 1, there is no global static variable in PHP this is done before. NET development, you can use the following methods to cache some data: View Plaincopy to Clipboardprint? public class Test {private ...

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