What does function mean in php?
function is a keyword used to declare user-defined functions.
The syntax structure of PHP declaration function
Function function_name($argument1,$argument2,$argument3,......$argumentn) { //函数代码code Return 返回值; }
Among them:
function_name: The name of the function to be created. This name will be used when it is called later. The function name should be unique, Because PHP does not support overloading. When naming functions, you need to follow the same principles as variable naming
. However, the function name cannot start with $, but the variable can.
argument: to be passed The value given to the function. The function can have multiple parameters, with commas between them. But the parameter items are optional and you can not pass any parameters when calling the function.
code: is when the function is called A piece of code that is executed when. If there are two or more statements, the code must be enclosed in curly braces "{}". However, if there is only one code, curly braces are not required.
Return: Returns the value required by the calling code. Any type can be returned, including lists and objects. This causes the function to immediately end its execution and pass control back to the line on which it was called.
Examples include:
function jia($a) { $b = $a+10; return $b; }
The above is a custom function, let’s see how to use it
echo jia('10');
The displayed result is 20
Here jia is the custom function name, so just give $ The result returned by any number is 10. This is a customized function. This example is very simple~ But by customizing the function, you will find that everything becomes better.
Recommended: "PHP Tutorial"
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!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SublimeText3 English version
Recommended: Win version, supports code prompts!

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

Dreamweaver CS6
Visual web development tools

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft
