Home >Backend Development >PHP Problem >PHP function naming convention

PHP function naming convention

王林
王林Original
2020-08-11 15:03:183953browse

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.

PHP function naming convention

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&#39;s name is ";
writeName("Hege");
echo "My brother&#39;s name is ";
writeName("Stale");
?>

Output result:

My name is Kai Jim Refsnes.
My sister&#39;s name is Hege Refsnes.
My brother&#39;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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn