In the PHP custom function creation definition is very simple, we just use function space followed by the functions of the name can be, the intermediate function can have parameters and related content, specifically as follows.
Using a custom function to implement the 99 multiplication table, a function is a block of code that can be executed at any time when needed.
To create a PHP function:
All functions use the keyword "function ()" to start
Named function – the name of the function should indicate its function. The function name begins with a letter or underscore.
Add "{" – the section after the opening curly brace is the code of the function.
inserting function code
Add a "}" – The function ends by closing the curly braces.
Example
A simple function that can output my name when it is called:
Using PHP functions
Now, we're going to use this function in our PHP script:
The output of the above code:
Hello world!
My name is David Yang.
That's right, David Yang is my name
Let's write a 99 multiplication table using a function.
<php?/** * 9*9 Multiplication Table * string fun_99 (int $start =1, int $end =1,bool $sort =true) * $start starting number must be between 1-9 and must be an integer * $end end value Must be between 1-9 and must be an integer and be greater than $start * $sort to indicate a sort, true to indicate a positive order, and false to indicate reverse */echo "