In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article will explain in detail the differences between php parameters and actual parameters. The editor thinks it is very practical, so I share it with you as a reference. I hope you can get something after reading this article.
Differences: 1. Formal parameters are several parameters in parentheses after the function name when the function is defined, and arguments are parameters in parentheses after the function name when the function is called; 2. Formal parameters are parameters that do not have practical meaning, and arguments are parameters with actual data significance.
Operating environment of this tutorial: windows7 system, PHP7.1 version, DELL G3 computer
The parameters of a function are divided into two types: formal parameters and actual parameters.
Formal parameter: a formal parameter, a parameter that has no practical meaning, is a parameter used when a function is declared and defined
Arguments: actual parameters, parameters with actual data meaning, are parameters used in function calls
1. Formal parameter
A formal parameter is a list of parameters (referred to as "formal parameter") in parentheses after the function name when defining a function, just like its name, the formal parameter itself has no specific value. Because the externally passed parameters need to be used in the function body, in order for the parameters to be passed in correctly, it needs to be passed through the formal parameters and the data in the function body, as shown in the following figure.
[example] the formal parameters of a function are as follows:
Where the variable $str in parentheses after the name of the function on line 2 of the code is the formal parameter of the function.
two。 Actual parameters
The actual parameter is several parameters (referred to as "argument") in parentheses after the function name when we call the function. The actual parameter and the parameter need to correspond one to one in order, and it will replace the corresponding variable value of the formal parameter in the function body. The parameter of the function can be a specific value or a variable. The actual parameters are shown in the following figure.
[example] the following code demonstrates the actual parameters used when calling a function:
Among them, 11 and 32 in parentheses after the function name on line 6 of the code are the actual parameters.
Note: the actual parameters must be the same as the number of formal parameters, and correspond one by one, otherwise the program will make an error.
[example] when calling a function, a fatal error occurs when the number of actual parameters is different from that of formal parameters:
The running structure is as follows:
Fatal error: Uncaught ArgumentCountError: Too few arguments to function add ().
This is the end of the article on "what is the difference between php parameters and actual parameters". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.