A function is a reusable block of code used to complete a specific task; a function can make the program more modular and have a good structure; after the function is defined, it can be called repeatedly in the program; the function is divided into Built-in functions and custom functions.
The real power of PHP comes from its functions: it has over 1000 built-in functions.
PHP user-defined functions (Recommended learning: PHP video tutorial)
In addition to the built-in PHP functions, we can create our own functions .
A function is a block of statements that can be used repeatedly in a program.
The function will not be executed immediately when the page is loaded.
Function will only be executed when called.
Creating user-defined functions in PHP
User-defined function declarations begin with the word "function":
Syntax
function functionName() { 被执行的代码; }
Note: Function names can start with letters or underscores (not numbers).
Note: Function names are not case-sensitive.
Tip: The function name should reflect the task performed by the function.
In the following example, we create a function named "writeMsg()". An opening brace ({) indicates the beginning of a function's code, while a closing brace (}) indicates the end of the function. This function outputs "Hello world!". To call this function, just use the function name:
Example
<?php function sayHi() { echo "Hello world!"; } sayhi(); // 调用函数?>
The above is the detailed content of what does php function mean. 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!

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

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

WebStorm Mac version
Useful JavaScript development tools
