The eighth chapter of PHP notes (not all)

Source: Internet
Author: User

8.1 functions are named; functions are independent; functions perform specific tasks; The function can be used to return a return value to the program function calling him to improve the reusability of the program to improve software maintainability and improve software development efficiency Complexity of Control program design PS: I don't see why, it doesn't work. Declaration format of the declaration function of the 8.2.1 function with 8.2 custom function
The function parameter ([parameter 1, Parameter 2, .... Parameter n]) {     
function Body returne return value;}
   Description:      (1) The first line of each function is the function header, which consists of the keyword function, function name, and argument list that declares the functions       (2) Each custom function must use the "function" keyword Declaration       (3) function name can represent the entire function, the name of the function follows the variable naming rules.                       php does not allow the use of function overloading, so it is not possible to set the duplicate function, It is better to specify a name for the function that describes its function       (4) The parentheses after the function name must be there when declaring the function.       (5) The function body is enclosed in curly braces after the function head       (6) Returns a value using the keyword return the calling function of the 8.2.2 function is executed only if it is called. Function name functions      1. Heard function name Call function      2. If the function has arguments, the parentheses after the function name are       3. There is a function when the function is returned, when it is finished. Return the value returned to the location of the calling function, so that the function name as a return value using the              8.2.3 function parameter list is by another, One or more parameters consist of each argument being an expression, separated by a good number. For parameters, there is a transitive relationship between PHP and the called function.   parameter: An expression argument after the function name that defines the function: the expression after the function name is called (easy to confuse) the  8.2.4 function's return value calls the function's script program cannot directly use the information inside the function body, but can pass the data to the caller by the key return  return function:     return statements can return any deterministic value of the function body to the function caller;      Return program control to the scope of the caller, that is, the Exit function. If a return statement is executed in the function, subsequent statements will not perform the  8.3 function and the structuredThe excellence of process structured programming       structured programs are easier to program. Complex problem simplification       structured programs easier debugging the range of  8.4php variables is also the scope of its entry. Variables can be divided into local variables and global variables according to the location of the  8.4.1 local variables are also called internal variables, is declared inside the function, its scope is limited to the function inside, it is illegal to use this variable after leaving the function.  8.4.2 global variables, also known as external variables, are defined outside the actual function, and are scoped to start with the definition of the variable and at the end of the program file. Because functions can be considered as separate program fragments in PHP, local variables are visible, so there are two ways to use global variables in functions that cannot use global variables directly:      Use the Global keyword to define the target variable to tell the function body Word variable to global variable       use special PHP custom $globals array  8.4.3 static variable local variable from storage can be divided into dynamic storage type and static storage type. If a variable is not declared as a static storage category, the default is dynamically non-provisioned storage space. Static variables: But the internal variables remain in memory after the function ends  functionparameters ([parameter 1, Parameter 2, .... Parameter n]) {
          function Body          returne return value;}

8.5 declares a function format that applies various forms of PHP functions 8.5.1 general Parameters: String Example(string name, int age, double height) 8.5.2 pseudo-type parameter function (not readable) format: Mixed FunnameMixed$ARHS) Mixed Funname( Nunmber$args) 8.5.3 Types of reference parameters

The eighth chapter of PHP notes (not all)

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.