General:
PHP JS
<?php

// This is where PHP code goes!

?>
<script language="JavaScript">

// This is where JavaScript code goes!

</script>
; is required to end a line. ; is optional to end a line.
Whitespace for formatting is ignored. Whitespace for formatting is ignored.
Use "." to concatenate. Use "+" to concatenate.
Comments:
PHP JS
// This line has been commented out.
# This line has been commented out.
/* This block of text
has been commented out.*/
// This line has been commented out.

/* This block of text
has been commented out.*/
Including External Scripts:
PHP JS
<? include("include.php"); ?> <script language="JavaScript" src="include.js"></script>
Variables:
PHP JS
$var1 = "string"; var var1 = "string";
$var2 = 100; // Integer
$var3 = "100"; // Numeric String

$var2 == $var3
$var2 !== $var3
var var2 = 100; // Integer
var var3 = "100"; // Numeric String

var2 != var3
!(var2 === var3)
Arrays:
PHP JS
$my_array = array("cheese","fishsticks","pants","42",69); var my_array = new Array("cheese","fishsticks","pants","42",69);
$my_array[count($my_array)] = "string"; or $my_array[] = "string";
$my_array[5] = "doom";
my_array[my_array.length] = "string";
my_array[5] = "doom";
Associative Arrays (Hashes):
PHP JS
$my_array = array('cheese' => "cheddar",'key' => "value"); var my_array = {'cheese':"cheddar",'key':"value"};
$my_array['name'] = "doom"; var my_array = new Object();
my_array['name'] = "doom"; <or> my_array.name = "doom";
Output:
PHP JS
echo("This text");
print($this_text);

// Strings and variables are interchangable in both.
document.write("This text");


// Strings and variables are interchangable.
Conditionals:
PHP JS
if($var1 == "test") { ... if(var1 == "test") { ...
elseif($var1 == "testing") { ... else if(var1 == "testing") { ...
Ternary Conditionals:
PHP JS
$var1 = ($var2 == "test") ? "yes" : "no" ; var var1 = (var2 == "test" ? "yes" : "no") ;
Loops:
PHP JS
for($i=0; $i<10; $i++) { ... for(i=0; i<10; i++) { ...
foreach($my_array as $key => $value) {
  $my_array[$key] = strtoupper($value);
}
for(key in my_array) {
  my_array[key] = my_array[key].toUpperCase()
}
while() { ... while() { ...
"Built-in" Functions/Methods:
PHP JS
$new_string = strtoupper($string); var new_string = string.toUpperCase();
$new_string = count($my_array); var new_string = my_array.length;
$new_string = strlen($string); var new_string = string.length;
$new_string = count($array); var new_string = array.length;
$string = "Pants are good!";
$new_string = substr($string,2); // "nts are good!"
$new_string = substr($string,2,6); // "nts ar"
$new_string = substr($string,-2,1); // "d"
var string = "Pants are good!";
var new_string = string.substr(2); // "nts are good!"
var new_string = string.substr(2,6); // "nts ar"
var new_string = string.substr(-2,1); // "d"
$new_string = explode("delimiter",$string); var new_string = string.split("delimiter");
$string = "Microsoft is good!";
$new_string = str_replace("good","evil",$string);
var string = "Microsoft is good!";
var new_string = string.replace(/good/,"evil");
Creating Your Own Functions:
PHP JS
function new_function($arg1,$arg2) {
  if($arg1 == $arg2) {
    return TRUE;
  }
  else {
    return FALSE;
  }
}
function new_function(arg1,arg2) {
  if(arg1 == arg2) {
    return true;
  }
  else {
    return false;
  }
}