Home >Backend Development >PHP Problem >What does function mean in php
function is a custom function
For example:
function jia($a) { $b = $a+10; return $b; }
The above is a custom function, see below See how to use it (recommended learning: PHP video tutorial)
echo jia(‘10’);
The displayed result is 20 //Here jia is the custom function name, so just give $a any number The returned results are all 10. This is a customized function. This example is very simple~ But by customizing the function, you will find that everything becomes better.
A function can be defined by the following syntax:
Pseudocode showing the purpose of the function
<?php function foo($arg_1, $arg_2, /* ..., */ $arg_n) { echo "Example function.\n"; return $retval; } ?>
Any valid PHP code has May appear inside a function, even in other function and class definitions.
The function name has the same naming rules as other identifiers in PHP. Valid function names begin with a letter or underscore, followed by letters, numbers, or underscores. It can be expressed as a regular expression: [a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*.
Note: When a function is conditionally defined, it must be defined before calling the function.
The above is the detailed content of What does function mean in php. For more information, please follow other related articles on the PHP Chinese website!