Concepts of form parameters and real parameters

Source: Internet
Author: User
What is a form parameter and an actual parameter? (I already know Baidu, but I don't know it, or I don't understand it ). For example, it is better. What is a form parameter and an actual parameter?
(I already know Baidu, but I don't know it, or I don't understand it ).
For example, it is better.

Reply content:

What is a form parameter and an actual parameter?
(I already know Baidu, but I don't know it, or I don't understand it ).
For example, it is better.

PHP doesn't know much about it, but I can use C to explain it to you. The principle is the same.
Form parameter. Indicates the type and name of the parameters used in your function.
For example

void fn(int a, int b){    return a+b;}

Here, a and B represent the form of parameters used by the function.
The real parameters are better understood. The actual parameters are the ones you actually use when you execute this function.

c = fn(1,2);

Here, values 1 and 2 are real parameters.

The form parameter is a shell prepared by the function for the value to be passed in, and the real parameter is the final input form parameter, that is, the actual value in the shell, in the function, you can use the shell to access the value in the shell.


  

The form parameter and the real parameter can be understood literally: it is a form parameter; and the actual parameter;

For example:

Function sum ($ a, $ B = 1) {return $ a + $ B; // $ a, $ B is the form parameter} sum (1, 2 ); // 1 and 2 are values of the real Parameter sum (1); // the value of $ B is not defined here, so the default value 1 is called, but this function is called. The real parameter is only $

More in-depth understanding

Function params () {return func_get_arg (); // none of the input parameters, but real parameters can be obtained through the func_get_arg () function} params (1, 2, 3, 4 ,....); // The function is called here, but the parameter (parameter) is not specified in the function. However, I can also pass the parameter (and the quantity is unlimited). The parameter of this object is the real parameter.

Placeholder parameter, passed Value

The parameter is also used to constrain the data type and number of calls.

That is, the difference between the transfer address and the transfer value.

For example, I will not describe the theories that I cannot understand. Do I still have an impression on the values in the definition domain and definition domain of high school? The real parameter is like the value in the definition field, and the form parameter is like the definition field. Qingpai

Function dosomething ($ a parameter ){

$ B = $ a real parameter;

}

When you write a function, the parameter required by the function is the form parameter.
When you call a function, the parameter used by the function is a real parameter.

function foo($a) {}

Does $ a have a value at this time? No, so it is a form parameter.

$b = 5;

Does $ B have a value at this time? Yes, so it is a real parameter.

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.