Variable sharing in PHP files included

Source: Internet
Author: User
I have encountered some problems in the PHP self-learning process, and may encounter common mistakes. Please forgive me! Thank you! For example, we have the following test case. php {code ...} b. php {code ...} however, in ZendStudio, there will be a warning of Undefinedvariable & #039; $ msg & #039;, although it does not affect... self-study PHPSome problems may cause common mistakes during the process. Please forgive me! Thank you!
The following test cases are available:
a.php


  

b.php


  

However, in Zend StudioUndefined variable '$msg'Warning, although it does not affect the running results, but it may affect the later maintenance or reading by others, so I would like to ask if there is any good way to solve this problem of "obsessive-compulsive disorder? Can Zend Studio not report this warning?

ViewtypechoThe following statement is displayed in the source code process:
/usr/themes/default/404.php


  
  Need ('header. php');?>

404-

Need ('footer. php');?>

ThattypechoHow to implement and use$thisAccessneed?
I noticedtypechoThe topic templates of are all used.$thisTo use the provided plug-ins or functions. What is the principle?

Reply content:

Self-studyPHPSome problems may cause common mistakes during the process. Please forgive me! Thank you!
The following test cases are available:
a.php


  

b.php


  

However, in Zend StudioUndefined variable '$msg'Warning, although it does not affect the running results, but it may affect the later maintenance or reading by others, so I would like to ask if there is any good way to solve this problem of "obsessive-compulsive disorder? Can Zend Studio not report this warning?

ViewtypechoThe following statement is displayed in the source code process:
/usr/themes/default/404.php


  
  Need ('header. php');?>

404-

Need ('footer. php');?>

ThattypechoHow to implement and use$thisAccessneed?
I noticedtypechoThe topic templates of are all used.$thisTo use the provided plug-ins or functions. What is the principle?

  1. Do not use bare global variables to wrap them into a class.

  2. A template is included by the method of an object and has the following scopes:$thisThis variable.

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.