Php function basic syntax custom function
PHP provides powerful functions, but this is far from enough, and programmers can create functions themselves as needed. This section begins to learn how to create functions.
In the actual development process, we need a lot of functions that need to be used repeatedly. These functions need to be used repeatedly. We can define functions (functions) and define them as functions (functions) as much as possible. When you use it, just click on its name.
Then let's learn the syntax of the custom function. The syntax is as follows:
Remember: you have to write more code to experiment!
The following characteristics were found in the above grammar rules, and the following words were not specified:
- The function starts with function
- function followed by a space, followed by a function name.
- The function name is basically the same as the variable naming rule, but the difference is: the function name is not case sensitive.
- The so-called parameter is actually a variable
- The function name is followed by parentheses, the parameters are enclosed in parentheses, and the parameters are all enclosed in  (brackets), which means the parameters can be filled or not.
- If there are parameters, the parameter can be followed by the (=) equal sign, and the equal sign is connected to the default value. Parameter values are also enclosed in  (brackets), representing optional
- After the function parameter variable, the main function is to pass the variable value outside the function to the function body. The variables of the function body and the variables outside the function are usually two different variables.
- The specific function (function body) in the function is enclosed in curly braces, which means that this is a functional interval of a function.
- Functions can have a return value or no return value, enclosed in  (brackets), representing optional.
- Return followed by a space, followed by a space followed by a return value. If there is a return, the code after return is not executed.
- The execution of the function has no order relationship and can be called at the position before the definition.
- The function cannot be defined twice, ie the function cannot be overloaded
We can prove these points little by little through experiments.
1. The function is a dog, where to call where, it will follow you
Php_cn this function, is not shown in three paragraphs: I am a dog?
3. The function name is the same as the variable naming rule, but the difference is: the function name is not case sensitive.
Through the above code, you will find three lines: If you are the guy who writes the code, we need to take more responsibility from the family