| attribute | scripting language | |||||
|---|---|---|---|---|---|---|
| general | name | |||||
| " | name meaning | Practical Extraction and Report Language | PHP Hypertext Preprocessor | |||
| " | interpreted? | yes | yes | yes | ||
| side | client-side | Client-side JavaScript (default) | no | no | ||
| " | server-side | Server-side JavaScript (rare) | yes | yes | ||
| " | price | free | free | free | ||
| " | browsers on which included | all | (none) | (none) | ||
| " | file extension | .js
| .pl
| .php
| ||
| " | case sensitive? | variables | yes | yes | yes | |
| " | " | nonvariables | no | |||
| embedding in HTML | short form | (none) | ||||
| " | long form | #!/usr/local/bin/perl
| ||||
| comments | C++ style | // comments go here
| (none) | // comments go here
| ||
| " | Unix style | (none) | # comments go here
| # comments go here
| ||
| " | C style | /* comments go here */ | (none) | /* comments go here */ | ||
| escape sequences | escaping character | \
| \
| \
| ||
| " | backspace | \b
| \b
| (none) | ||
| " | form feed | \f
| \f
| (none) | ||
| " | newline | \n
| \n
| \n
| ||
| " | carriage return | \r
| \r
| \r
| ||
| " | horizontal tab | \t
| \t
| \t
| ||
| " | vertical tab | (none) | \v
| \v
| ||
| " | single quote | \'
| \'
| \'
| ||
| " | double quote | \"
| \"
| \"
| ||
| " | backslash | \\
| \\
| \\
| ||
| " | dollar sign | (none) | (none) | \$
| ||
| formatting characters? | no | yes | no | |||
| line terminator required? | no | yes | yes | |||
| line terminator | ;
| ;
| ;
| |||
| standard I/O | print/write | 1 string | document.write("Hello world");
| print "Hello world.";
| print "Hello world.";
| |
| " | " | 2 strings | document.write("Hello " + "world");
| print "Hello " . "world.";
| ||
| " | " | number | document.write(3);
| print 3;
| ||
| " | " | variable | document.write(y);
| print "$y";
| print "$y";
| |
| datatypes | declare constants | const PI = 3.14159;
| use constant PI => 3.14159;
| define("PI", 3.14159);
| ||
| " | type casting | array | (array) | |||
| " | " | boolean | (boolean) | |||
| " | " | integer | (integer) | |||
| " | " | object | (object) | |||
| " | " | real | (real) | |||
| " | " | string | (string) | |||
| " | variable prefix | scalars | scalarname | $scalarname | $scalarname | |
| " | " | arrays | arrayname | @arrayname | $arrayname | |
| " | " | hashes | hashname | %hashname | $hashname | |
| string delimiters | "stringhere" | "stringhere" 'stringhere' | "stringhere" 'stringhere' | |||
| operators | arithmetic operators | addition | +
| +
| +
| |
| " | " | subtraction | -
| -
| -
| |
| " | " | multiplication | *
| *
| *
| |
| " | " | division | /
| /
| /
| |
| " | " | exponen- tiation | (none) | **
| (none) | |
| " | " | modulus | %
| %
| %
| |
| " | concat- enation | + | . | . | ||
| " | assignment | =
| =
| =
| ||
| " | shortcut assignment operators | increment | +=
| +=
| +=
| |
| " | " | decrement | -=
| -=
| -=
| |
| " | " | multiplication | *=
| *=
| *=
| |
| " | " | division | /=
| /=
| /=
| |
| " | " | modulus | %=
| %=
| %=
| |
| " | " | exponen- tiation | (none) | **=
| (none) | |
| " | " | concat- enation | +=
| .=
| .=
| |
| " | logical operators | and | &&
| &&
| &&
| |
| " | " | or | ||
| ||
| ||
| |
| " | " | exclusive or | (none) | (none) | XOR
| |
| " | " | not | !
| !
| !
| |
| " | equality operators | equality | ==
| ==
| ==
| |
| " | " | equivalence | ===
| ===
| ||
| " | " | not equals | !=
| !=
| !=
| |
| " | comparison operators | less than | <
| <
| <
| |
| " | " | greater than | >
| >
| >
| |
| " | " | less than or equal | <=
| <=
| <=
| |
| " | " | greater than or equal | >=
| >=
| >=
| |
| " | " | ternery | (b == 5) ? a="true" : a="false";
| ($b == 5) ? $a="True" : $a="False";
| ($b == 5) ? $a="true" : $a="false";
| |
| bitwise operators | and | &
| &
| &
| ||
| " | or | |
| |
| |
| ||
| " | exclusive or | ^
| ^
| ^
| ||
| " | not | ~
| ~
| ~
| ||
| " | shift left | <<
| <<
| <<
| ||
| " | shift right | >>
| >>
| >>
| ||
| " | zero-fill shift right | >>>
| (none) | |||
| data structures | arrays first need to be created? | yes | no | no | ||
| " | array assignment | individual | names[0] = "Peter";
| $names[0] = "Peter";
| $names[0] = "Peter";
| |
| " | " | multiple | @names = ("Peter", "Paul");
| $names = array("Peter", "Paul");
| ||
| " | class creation | function Staff(...)
| struct Staff =>
| class Staff
| ||
| " | class instantiation | employee = new Staff();
| $employee = new Staff();
| $employee = new Staff();
| ||
| " | field assignment | employee.name = "Mary";
| $employee->name("Mary");
| $employee->name = "Mary";
| ||
| control structures | conditional statements | if | blocked | if (expression)
| if (expression)
| if (expression)
|
| " | " | " | un- blocked | if (expression)
| ||
| " | " | else | blocked | if (expression)
| if (expression)
| if (expression)
|
| " | " | " | un- blocked | if (expression)
| ||
| " | " | else if | blocked | if (expression)
| if (expression)
| if (expression)
|
| " | " | " | un- blocked | if (expression)
| ||
| " | " | switch | switch(varname)
| (none) | switch($varname)
| |
| " | loops | for | for ($i=1; $i<=10; $i++)
| for ($i=1; $i<=10; $i++)
| for ($i=1; $i<=10; $i++)
| |
| " | " | for each / for in | for (varname in arrname) { ... } | foreach (@arrname) { ... } foreach $varname (@arrname) { ... } | foreach (arrexpr as $value) { ... } foreach (arrexpr as $key => $value) { ... } | |
| " | " | while | while (expression) { ... } | while (expression) { ... } | while (expression) { ... } | |
| " | " | do while |
do { ... } while (expression); |
do { ... } while (expression); |
do { ... } while (expression); | |
| " | break | break;
| last;
| break;
| ||
| " | continue | continue;
| next;
| continue;
| ||
| " | functions | no returned value, argument list |
function functionname() { ... } |
sub functionname() { ... } |
function functionname() { ... } | |
| " | " | no returned value, no argument list | (none) |
sub functionname { ... } | (none) | |
| " | " | returned value, argument list |
function functionname() { ... return value; } |
sub functionname(){ ... return value;} |
function functionname(){ ... return $value;} | |
| " | " | returned value, no argument list | (none) |
sub functionname{ ... return value;} | (none) | |
| " | " | random number | $rn = Math.random();
| $rn = rand($ul);
| srand ((double) microtime( )*1000000);
| |
| " | regular expressions | POSIX style | no | no | yes | |
| " | " | Perl- style | yes | yes | yes | |
| file I/O | open | to read | (none) | open($fh, "books.txt");
| $fh = fopen("books.txt", "r");
| |
| " | " | to append | (none) | open($fh, ">>books.txt");
| $fh = fopen("books.txt", "a");
| |
| " | " | to overwrite | (none) | open($fh, ">books.txt");
| $fh = fopen("books.txt", "w");
| |
| " | read | @userdata = $fh;
| $userdata = fread($fh, 1024);
| |||
| " | write | print $fh "$article";
| fwrite($fh, $article);
| |||
| " | close | close($fh);
| fclose($fh);
| |||