Javascript | PHP | |||
comments | /* comment */ or // comment |
|||
should be declared at the beginning var i,j,k; |
no declaration needed | |||
Datatypes | loose typing | loose typing | ||
Names | must start with $ | |||
Strings between | " |
" |
||
Arrays (long form) | var day = new Array(length); day[0] = "monday"; day[1] = "tuesday"; |
$day[0]="monday"; $day[1]="tuesday"; |
||
Arrays (short form) | var day= new Array("monday", "tuesday", wednesday"); | $day=array("monday","tuesday", wednesday"); | ||
associative arrays (long form) | $teacher[CPT106]="Prisner"; $teacher[STA111]="Stanford"; |
|||
... for numbers | + - * / | + - * / | ||
add1, subtract 1 | ++ -- | ++ -- | ||
concatenation of strings |
+ |
. |
||
comparison |
== != < > <= >= |
|||
... for Boolean expressions |
&& || |
&& and || or |
||
if | if {condition} {what1} else {what2}; | |||
for | for ($i=0; $i < 10; i++) {statements} | |||
while | while (something is true) {statements} | |||
foreach | (since PHP4) {what} | |||
onload="fctname()" | ||||
onMouseOver=... | ||||
function fctname(argnames){} | function fctname(argnames){} | |||
Erich Prisner, 11/22/2003