One thing you need to be careful of, and has caught me out a few times when jumping from PHP to Javascript, is ‘new lines’….
In JavaScript a new line suggests the end of a statement and the start of a new one… Where in PHP, the line can continue over several lines and doesn’t stop until you add the semi-colon…
So, two statements could be written like this:
Statement one Statement two
Or they could be written like this:
Statement one; Statement two;
It is generally considered best practice, however, to do both—separate statements by a semicolon and a new line:
Statement one; Statement two;
Main Category