1) function example
Php: function inc ($ val)
{Return $ val + 1 ;}
The process is also a function, but there is no return value.
Jscript, javascript:
Function inc (val)
{Return val + 1 ;}
The process is defined as above.
VBScript:
Function inc (val)
Inc = val + 1
End function
Procedure
Sub inc2 (byref val)
Val = val + 1
End sub
2) Class Example
Php:
Class parent {
Var property;
Function parent (){}
Function method (){}
}
/* Inherit */
Class child extends parent {var property = new value;
}
Jscript or javascript:
Class parent {
Property = value
Function parent () function method (){}}
Inheritance is not supported (the original document is like this, but it seems that inheritance is supported now)
Vbscript:
Does not support classes (the original article is like this, but now also supports)
3) variable range
Php: variables allow global variables in functions or out-of-class definitions. You can also define local variables in functions and classes.
Unlike other languages, when using variables, you must name a global variable and use the keyword global in functions and classes.
$ Globalvar = 1;
Function show_global (){
Global $ globalvar;
Print $ globalvar;
}
Jscript or javascript:
Similar to PHP, global variables do not need to be declared in functions.
Vbscript:
Similar to PHP, global variables do not need to be declared in functions and procedures.
4) Access Reference
Php: Use keywords in function parameters.
Jscript or javascript
Simple access through variables, referencing complex types in Functions
Vbscript:
Use the ByRef keyword in the Sub or function parameters.
5) default parameters
Php: function A (param1 = "abc") is supported ")
Others are not supported.
6) return a reference (I do not know how to flip)
Php: function getarray123 (){
$ Val = array (1, 2, 3 );
Return & $ val;
}
Then use
$ Val = & getarray123 ();
Other unsupported
7) Class
Php: better support
Others: Average
8) handle errors
Php: Use @ to prevent running errors.
$ Val = @ function_can_fail ();
@ The range is the current declaration. The final error can be checked in $ php_errormsg. If you set track_errors = On in PHP. ini.
Javascript or jscript:
Use try and catch.
Try {
Function_can_fail ()
} Catch (err) {Response. Write (err)
}
Vbscript:
Ignore running errors using On Error Resume Next
The new version also supports try and catch.
In addition, there is a comparison about language. If you are interested, you can translate it.