Functions for beginners to PHP

The real power of php lies in its functions. In php, it provides more than 1,000 built-in functions.To view the complete php built-in functions, please refer to the php manual. This chapter will tell you how to Create a function in php,The function is executed by calling

Create function:

function msg(){

Execution code

}

Function to be called

Note:The function name should reflect its function. The function name starts with a letter or underscore and cannot start with a number

In order to add more functions to the function, we can add parameters to the function

For example, in the above example: there are brackets after the function name, in which we can add parameters. The parameters are similar to variables

alert('$cnt')"; //弹出窗口 echo ""; //跳转到那个页面 } msg("大家好",'//m.sbmmt.com'); ?>

Note:When the msg function is called , will pass "Hello everyone" and the address of php.cn to the function, first pop up Hello everyone, and then jump to the php.cn page

Return value of php function

If you need the function to return a value, please use the return statement


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