I have a single dish, and I don't know much about it in some areas of study. if I am not good at searching, I will send it to ask you. Thank you for your answers and help. Example: {code ...} a. php pseudocode: {code ...} b. php code: {code ...} c. php {code ...} goals to be achieved... I have a single dish, and I don't know much about it in some areas of study. if I am not good at searching, I will send it to ask you.
Thank you for your answers and help.
Example:
There are currently three files in a. php B. php c. php
The pseudocode a. php is as follows:
B. php code is as follows:
c.php
The goal is to directly read the variable value in the C. PHP file.
The general logic is as above. I personally think this is similar to assign/display in the framework, but I don't know how to implement it.
The above code reports an error:Notice: Undefined variable: str
I hope you can give me some advice (or write habits ).
Thank you.
Reply content:I have a single dish, and I don't know much about it in some areas of study. if I am not good at searching, I will send it to ask you.
Thank you for your answers and help.
Example:
There are currently three files in a. php B. php c. php
The pseudocode a. php is as follows:
B. php code is as follows:
c.php
The goal is to directly read the variable value in the C. PHP file.
The general logic is as above. I personally think this is similar to assign/display in the framework, but I don't know how to implement it.
The above code reports an error:Notice: Undefined variable: str
I hope you can give me some advice (or write habits ).
Thank you.
global $array;
Only modified the scope of $ array,extract($array);
It is executed in the function, so the $ str scope is still inside the function. you can var_dump ($ arr ['str']) in c. php.
As for what you said, "I personally think this part is similar to the assign/display in the framework" and "but I don't know how to implement it", you don't know how to implement it, why do you think this is similar to assign/display in the framework?
In this example, the same is true if you use a class. you do not need to define three files separately and it looks comfortable. However, the functions you use indicate that you cannot perform object-oriented thinking well, the progress is still unstable. it makes no sense for us to tell you the sprint skills.
PHP
All the variables have scopes.assign/display
Other forms of template engines areextract
Output variables andinclude
The imported template file is placed in the same function. Only in this way can the variable scope be consistent and the value of the variable can be obtained from the introduced file. However, if you split two operations into different functions, you certainly cannot access each other. Let alonec.php
To get the value of the variable, yousay("str","thinks");
And cannot be obtained directly.
It seems that you have not really understood the scope of global and the internal variables of the function. We recommend that you check their concepts or usage again!
According to your ideas, $ str in var_dump ($ str); is the parameter 'str' in extract ($ array ', in fact, what you want var_dump to get at this time is the $ str variable in the say function.
This is nothing more:
function a(){ $str = '123';}a();var_dump($str);
You cannot get $ str.