A function is to encapsulate a piece of code that is used to complete a specific function. A popular understanding of a function: a block of code that can complete a certain task, just like the building blocks used by children to build a house. It can be used repeatedly. When used, it can be used immediately without considering its internal structure. Below we will introduce to you the definition and use of php functions.
Recommended tutorial: PHP video tutorial
##Custom function
function 函数名([参数1, 参数2, ……]){ 函数体…… }
Description of each part
Function: Keywords that must be used when declaring a function Function name: An identifier that must conform to PHP, and the function name is unique , not case sensitive [Parameter 1, Parameter 2...]: The value passed to the function from the outside world, it is optional, use commas "," to separate multiple parameters. Function body: The main body of the function definition, a code segment specifically used to implement a specific function. Return value: You need to use the return keyword to pass the data to be returned to the caller.The above is the detailed content of Definition of functions in php. For more information, please follow other related articles on the PHP Chinese website!