Ask a basic question, can you show the declaration variables
Source: Internet
Author: User
Ask a basic question, can you show the declaration variables?
If you use a variable in a function class
$c = "AAA";
The engine is to go to the global find this variable, can not find and then create it?
------Solution--------------------
What does it mean?? If you can't find it, you can't find it. You're looking for $c in the function. That's a local variable, and he's not going to make a claim to find the whole thing or create it automatically. If you use it, there's no one there.
------Solution--------------------
Does PHP have a display and an implicit declaration? I don't know.
------Solution--------------------
Statement to Global
------Solution--------------------
Yes, that's global!.
------Solution--------------------
Global $aaa; A global variable is declared in a class, but can be used without global variables in a class, so reusability is not high, and debugging a global variable is more troublesome than a local variable.
------Solution--------------------
Unless declared as global, the default is local, and PHP is different.
------Solution--------------------
Global meaning I'm going to use this variable now, I've already defined it in "somewhere else."
and $globals[' var ') are generally the same effect
PHP definition is much different from C + + Java
$c = "AAA", if there is "AAA" in memory
Might just be a pointer to not declaring AAA
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