Function函数

  • 格式:doc
  • 大小:23.50 KB
  • 文档页数:2
函数实际上是一个统一的代码块,你可以随时调用它。
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)
加上一个“}”:函数书写完毕后, 必须加上“}”符号。
Example
案例
A simple function that writes my name when it is called:
下面是一个简单的PHP函数案例,当我们调用它时,它可以输出我们的名字:
VB Function关键字
Function函数是包含在Function和End Function语句之间的一组VBScript语句。Function函数与Sub过程类似。但Function函数可以有返回值。可以使用参数。如果Function函数没有任何参数,则Function语句必须要包含空括号。Function函数通过函数名返回一个值。返回值的数据类型是Variant.
语法:Functionn
编辑本段
Javascript function关键字
在脚本语言javascript中,function是定义一个函数的关键字,通常形态是
function函数名(参数1 [参数2])
{
函数体
return返回值
}
其中也可以不返回值。
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
<html><body>
<?phpfunction writeMyName() { echo "Kai Jim Refsnes"; }
writeMyName();?>
</body></html>
给函数命名:最好的命名方法是,函数拥有
的名称和它所表现的功能相一致。名字可以包含字母或下划线 (不可以包含数字)。