Syntax for Php,jscript and VBScript functions and classes

Source: Internet
Author: User

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.

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.