> 其他 >
function()函数的具体用法
请大侠具体告知,
人气:111 ℃ 时间:2020-09-12 14:49:48
解答
函数实际上是一个统一的代码块,你可以随时调用它.
Creating PHP functions:
创建PHP函数的方法:
All functions start with the word "function()"
所有函数的开头必须加上“function()”
Name the function - It should be possible to understand what the function does by its name. The name can start with a letter or underscore (not a number)
给函数命名:最好的命名方法是,函数拥有的名称和它所表现的功能相一致.名字可以包含字母或下划线(不可以包含数字).
Add a "{" - The function code starts after the opening curly brace
加上一个“{”:函数的代码必须写在“{”符号之后.
Insert the function code
插入一段函数代码
Add a "}" - The function is finished by a closing curly brace
加上一个“}”:函数书写完毕后,必须加上“}”符号.
Example
案例
A simple function that writes my name when it is called:
下面是一个简单的PHP函数案例,当我们调用它时,它可以输出我们的名字:


推荐
猜你喜欢
© 2024 79432.Com All Rights Reserved.
电脑版|手机版