Function: Refers to a collection of code that has a function of some kind. When this function is needed, we go to execute (call) the corresponding function. Structured programming, which encapsulates functionality into an independent structure. Abstract programming. Define functionality function each time you use the feature. Turn to now make the function as a tool, then use the tools. The function must first define the reuse. According to the definition of the function is divided into: system functions and user functions. The basic syntax of a function: Defines the syntax of a function: function function name (parameter) {function body} Call function's syntax: function name (passed to function argument). The basic components of functions: Function name function of the flag parameter function execution of some data reference function body (the code block to implement function function) function return value (function execution result, a feedback information) definition: Call: The function name part, the rule reference variable name naming rules, but the functions are not case-sensitive. But note Advice How to define how to call. The parameter part of the function: formal parameter: The function is defined as the parameter used, which is called the formal parameter. The formal argument is not of a specific value. A value is assigned only when it is called. Abbreviation formal parameter. Actual parameters: When a function is called, it is passed in a meaningful parameter according to the rules of formal parameters. This is called the actual parameter, referred to as the real argument. Typically, formal parameters are passed as a value in a function call, to obtain the value of the actual parameter. is relative to value passing, as well as reference passing. If you need parameter reference passing, you need to add the reference symbol & at the time of the definition, before the formal parameter. At this time when calling max3: When we modify the value of the variable x,y,z in the function body, this will have a different effect on A,b,c: If the parameter takes up a lot of resources, in order to improve efficiency, do we adopt a value or a reference? References. is not a requirement so the parameters are or are not some way of passing, can be set on the parameters alone. Default value for parameter: We can set the default value for the parameter of the function when defining the function. So when we call the function, if we don't pass the data for this parameter, we use the default value instead. function return value: function is to use RThe Eturn statement flag returns a value. It is usually required that each function has a return value, but the syntax can still have no return value. When the function executes to the return statement, the function runs the end. means that all function bodies after the return statement do not need to be executed again. How many return values can a function have? One. How many return statements can I have? Multiple. A function usually has only one return value, what happens if the function of a function requires to return two data? How do you make a function affect two values at the same time? Two value is packaged into a collection type of data. Using reference passing of parameters, many of the functions of PHP are adopted by reference pass to a function to handle multiple return values: Hint: If the argument is a reference pass, then the call must pass a variable. Because only variables can refer to delivery. SCOPE issues: The scope of variables, because there are functions will have scope division. When a variable is defined, it can be used in which code. A variable is bound to which scope. You need to know what scope php has: global scope. The function belongs to the global scope outside. Variables defined in the global scope are visible within the global scope. Local scope. Within the function, it is a function that forms a local scope. Variables defined within a local scope are locally visible. A super global: can be either within a function or outside of a function. In local scope access global scope variables. You need to use the keyword global to declare a variable to be global in a local scope. In addition to using the Global keyword, you can use the following method: PHP puts all the defined global variables into an array. This array is $globals (Super Global). Each element of globals is a global variable, and the subscript of the element is the global variable name, and the value of the element is the value of the variable. Local scope is generated when the function is called. Similarly at the end of the function run, the scope of the function disappears, and all the variables within the scope should disappear. Global scope is generated when the PHP script runs . Disappears at the end of the script run. Variables within the global scope should also disappear. In PHP, static variables for local scopes are supported. Scopes also belong to aA local scope. But since he is static, the static variable does not disappear after the function is run, and it retains the original processed value. Static local variables that take effect only within the scope of the current function. Simple summary: Ordinary global: function outside the ordinary local: function inside the Super global: all local static local: the current function, the function end does not disappear. Can be reused the next time it is called. In the local use of global: global $GLOBALS [] The role of reference passing of job parameters? Complete the Yang Hui's triangle: The first column and the diagonal are all 1, in addition, the value is = above the top of the value on the left shoulder. 1 11 121 1331 14641 15101051 1615201561 are defined as a function Yanghui (7); parameter is the number of rows. TIP: Use double loop and array operations to complete print star requirements define a function xingxing (4);