Home > Backend Development > PHP Problem > What does function mean in php

What does function mean in php

(*-*)浩
Release: 2023-02-23 16:52:02
Original
4323 people have browsed it

What does function mean in php

function is a custom function

For example:

function jia($a) {
$b = $a+10;
return $b;
}
Copy after login

The above is a custom function, see below See how to use it (recommended learning: PHP video tutorial)

echo jia(‘10’);
Copy after login

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;
}
?>
Copy after login

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!

Related labels:
php
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template