Ask a basic related question. can I display the declared variables?

Source: Internet
Author: User
Ask a basic question: Can I display the declared variables? If you use a variable $ c & quot; aaa & quot; in the function class, the engine first searches for this variable globally and creates it after it is not found? ------ Solution -------------------- what do you mean ?? If it cannot be found, it cannot be found. If you look for $ c in the function, it is a local variable, and he will not make a claim to find the global variable or create it automatically. If you use it, you will not have it. ------ Ask a basic question: Can I display the declared variables?
If a variable is used in the function class
$ C = "aaa ";
The engine first looks for this variable globally. can't it be found before creating it?

------ Solution --------------------
What do you mean ?? If it cannot be found, it cannot be found. If you look for $ c in the function, it is a local variable, and he will not make a claim to find the global variable or create it automatically. If you use it, you will not have it.
------ Solution --------------------
Does php display and implicit declaration? I don't know.
------ Solution --------------------
Declare to global
------ Solution --------------------
Yes, it's global!
------ Solution --------------------
Global $ aaa; global variable declaration in the class, but global variables are not used in the class, so the reusability is not high, and debugging and tracing a global variable is more troublesome than a local variable.
------ Solution --------------------
Unless declared as global, PHP is local by default.
------ Solution --------------------
Global means I want to use this variable now. I have defined this variable as early as "somewhere else ".
And $ GLOBALS ['var ']).
Definitions in php differ greatly from those in C ++ java.
$ C = "aaa"; if the memory contains "aaa"
It may be that a pointer is redirected without declaring aaa.

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.