1 Examples of functions
Php:function Inc ($val)
{return $val 1;}
A procedure is also a function, except that there is no return value.
JScript, javascript:
Function Inc (VAL)
{return val 1;}
The definition of the process is ibid.
VBScript:
Function Inc (VAL)
inc = Val 1
End Function
Procedure
Sub Inc2 (ByRef val)
val = val 1
End Sub
2 Examples of classes
Php:
Class Parent {
var property;
function parent () {}
Function method () {}
}
* * Continue * *
Class Child extends Parent {var property= new value;
}
JScript or javascript:
Class Parent {
Property=value
function parent () function method () {}}
does not support continuation (the original is the case, but it seems to support it now)
VBScript
Class is not supported (this is the original, but it is now supported)
3) The scope of the variable
PHP: Variables defined outside a function or class are agreed to be global variables, or local variables can be defined in functions and classes.
Unlike other languages, when using variables, you have to name a global variable that uses the key word global in functions and classes.
$globalvar = 1;
function Show_global () {
Global $globalvar;
Print $globalvar;
}
JScript or javascript:
Like PHP, you don't need to declare a global variable in a function.