PHP, & nbsp; JScript & nbsp; and & nbsp; VBScript & nbsp;

Source: Internet
Author: User
1) function example php: functioninc ($ val) {return $ val + 1;} is also a function, but no return value. Jscript, javascript: functioninc (val) {returnval + 1;} process definition is the same as above. VBScript: functioninc 1) function example
Php: function inc ($ val)
The {return $ val 1;} 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 (){}
}/* Continuous */
Class child extends parent {var property = new value;
} Jscript or javascript:
Class parent {
Property = value
Function parent () function method () {}} does not support continuity (the original article is like this, but it seems to support it now)
Vbscript:
Does not support classes (the original article is like this, but now it also supports) 3) scope of variables
Php: variables are defined as global variables in functions or out-of-class. you can also define local variables in functions and classes.
Unlike other languages, when applying variables, you must name a global variable to apply 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, you do not need to declare global variables in functions and processes. 4) visiting references
Php: the keyword of the application, in the parameter of the function
Jscript or javascript
Simple variables are used to reference complex types in functions.
Vbscript:
Apply the ByRef keyword to Sub or function parameters. 5) default parameters
Php: Support function A (param1 = 'abc ')
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 apply $ val = & getarray123 ();
Others do not support 7) class
Php: better support
Others: Generally 8) handle errors
Php: application @ prevents running errors. $ val = @ function_can_fail (); @ category 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:
Apply try and catch. try {
Function_can_fail ()
} Catch (err) {Response. Write (err)
}
Vbscript:
Application On Error Resume Next negligent running Error
The new version also supports try and catch. In addition, there is an article about language comparison. if you are interested, you can also translate it.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.