Basic functions of PHP development tutorial

1. Overview of PHP functions

The real power of PHP comes from its functions.

In PHP, more than 1000 built-in functions are provided.

Function is function. Calling a function is calling a function.

2. PHP built-in functions

The date() and rand() functions we used earlier are all built-in functions of the system. Details When you use it in the future, please check the PHP manual. There are detailed examples above. In the advanced tutorials that follow, there will also be an introduction to commonly used functions. In this chapter, our focus is on how to create our own functions.


3. PHP custom function

1. Create a function

Syntax:

function functionName()
{
Code to be executed;
}

PHP function guidelines:

  • The name of the function should hint at its function

  • The function name starts with a letter or underscore (not a number)

Note : There is no semicolon after the curly braces

2. Call the function

Syntax:

functionName;

Write Function names can be separated by semicolons

A simple example: the code is as follows


##4. Add parameters to the custom function

When calling a custom function, pass in point information to the function.

Example: The code is as follows

This method of adding parameters will be very common in our future study and work


5. The return value of the function

If you need to let the function return A value, use the return statement.

Example, the code is as follows

Continuing Learning
||
submit Reset Code
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!