Home > Article > Backend Development > PHP function naming convention
php function naming convention: 1. The name of the function should indicate its function; 2. The function name starts with a letter or underscore; 3. The function name cannot start with a number. Functions are executed by calling functions, and we can call functions anywhere on the page.
Function naming convention:
(Recommended tutorial: php graphic tutorial)
The name of the function should hint at its function
The function name starts with a letter or underscore (not a number)
Functions are executed by calling functions. We can call functions anywhere on the page.
In order to add more functions to the function, we can add parameters, which are similar to variables. Parameters are specified within a bracket after the function name.
(Video tutorial recommendation: php video tutorial)
Example:
<?php function writeName($fname) { echo $fname . " Refsnes.<br>"; } echo "My name is "; writeName("Kai Jim"); echo "My sister's name is "; writeName("Hege"); echo "My brother's name is "; writeName("Stale"); ?>
Output result:
My name is Kai Jim Refsnes. My sister's name is Hege Refsnes. My brother's name is Stale Refsnes.
The above is the detailed content of PHP function naming convention. For more information, please follow other related articles on the PHP Chinese website!