For illustrative purposes, I'll use different colors to illustrate the nature of the paragraph.
This is a question about defining arrays.
is in a framework where a method of consolidating arrays is first defined in the class
/**
* Output template content array, other variables do not allow direct output from the program to the template
*/
private static $output _value = Array ();
public static function output ($output, $input = ") {
Self::getinstance ();
Self:: $output _value[$output] = $input;
}
In the actual application, in a file, this is written
Plate information
$model _web_config = Model (' Web_config ');
$web _html = $model _web_config->getwebhtml (' index ');
Tpl::output (' web_html ', $web _html);
And then it's written here in the template.
Okay, here's my question:
The data in the array library is obtained from the above series of calculations, and the data is placed in the array. At this point in the template of the first to know the name of the array is called, and then through the subscript with the corresponding values in the array can be obtained, then my question came, here is why the array called $output it?
The name is casual or there is a context of the agreement, I looked at the above, there is no definition of the name, it suddenly appeared, so let people stunned! Harry
My current understanding: perhaps some would say that this sentence tpl::output (' web_html ', $web _html); the output in the word says, I don't think so, because here it's a method name, not an array name! Supposedly, the/** has been defined above.
* Output template content array, other variables do not allow direct output from the program to the template
*/
private static $output _value = Array (), why not $output_value do the array name here, but instead use $output to do the array name,
Reply to discussion (solution)
It is possible to define $output this array in the Tpl::output function.
Look at the questions you've been asking and find out you're not a beginner (sometimes the level of the problem is high)
So how can you not know the formal parameters when the function (method) is defined?
public static function output ($output, $input = ") {
Self::getinstance ();
Self:: $output _value[$output] = $input;
}
Two incoming parameters for the output method, you gotta give him a name, right? How else do you know who's Who?
You can't always call the first argument, the second argument.
Executive Tpl::output (' web_html ', $web _html); When
The ' web_html ' corresponds to the parameter $output
$web _html is the corresponding parameter $input
It is possible that the output method defines the
$web _html = Array (' index ' = ' xxx '), output (' web_html ', $web _html), function output ($key, $value) {global $output; $ output[$key] = $value; return $output;} echo $output [' web_html '] [' index '];
Other places may be assigned, such as: $output = $output _value;
It depends on how the whole class is written.
It is possible to define $output this array in the Tpl::output function.
I have a reminder that there's really
Assigning a template variable to a value
$output = self:: $output _value;
Look at the questions you've been asking and find out you're not a beginner (sometimes the level of the problem is high)
So how can you not know the formal parameters when the function (method) is defined?
public static function output ($output, $input = ") {
Self::getinstance ();
Self:: $output _value[$output] = $input;
}
Two incoming parameters for the output method, you gotta give him a name, right? How else do you know who's Who?
You can't always call the first argument, the second argument.
Executive Tpl::output (' web_html ', $web _html); When
The ' web_html ' corresponds to the parameter $output
$web _html is the corresponding parameter $input
You didn't see what I was asking.