1. Variable scope and static variables
Function parameters and parameter reference transfer
Function return Value and reference returns
Import of external files
Inspection of system built-in functions
Variables The scope of a variable is also called the scope of a variable. The scope of a variable is the context in which it is defined (also the scope in which it takes effect). Most PHP variables have only one valid scope, and this single scope also includes files introduced by include and require.
global keyword
$GLOBALS and other super-global arrays
Static variables are only in Exists in the local function scope, and its value will not disappear when the program execution leaves the scope.
static keyword
1. Only initialize once
2. Assignment is required during initialization
3. The value will be retained every time the function is executed
4. The modified function is local and is only saved inside the function
5. The number of function calls can be recorded to terminate the recursion under certain conditions
function myFunc(){ static $a = 1; echo $a++; } myFunc(); //1 myFunc(); //2 myFunc(); //3
Functions are passed by value by default, if you want the function to modify its value, you must pass it by reference.
2. The return value of the function
The value is returned through the optional return statement
Any type including an array or object can be returned
The return statement will terminate the execution of the function and return control to the control point of the function
If return is omitted, the return value is null
It is impossible to have multiple return values
To return a reference from a function, you must use the reference operator when declaring the function and assigning the return value to a variable. Import of external files
include/reqlude Difference warning/fatal error include_once/reqlude_once
3. System built-in functions
Time and date: date(), strtottime(), time(), miketime(), microtime(), date_default_timezone_set()
IP processing function: iptolong(), longtoip()
Print processing: print(), printf(), print_r(), echo, sprintf(), var_dump() , var_export()
Serialization and deserialization functions: serialize(), unserialize() https://www.cnblogs.com/yamtsin/p/5922872.html
String Processing function: implod()
Problem-solving method:
Focus on memorizing the relevant content of the PHP function definition, understand the variable scope, static variables, function parameters, and return values, focus on memorizing the relevant content Built-in function for summarization.
If you want to know more, please go to
PHP video tutorialThe above is the detailed content of PHP general knowledge review: custom functions and internal functions. For more information, please follow other related articles on the PHP Chinese website!