Programming Syntax
Syntax is the way a command can be written and a description of what is allowed and what is not allowed.
Here I will use the standard syntax layout unless I have a good reason to do otherwise with italics indicating something that the user customizes and square bracket indicating something that is optional. For instance the PHP if command syntax:
if (test) {
[statements;]
}
indicates that you start by typing if (
. Then you type whatever condition you want to be evaluated. Then you type ) {
then it is optional to place one or more statements here. Then you finish the if statement with a }
.
Here is a table of common PHP commands:
addition | $x+$y |
subtraction | $x-$y |
multiplication | $x*$y |
division | $x/$y |
modulus | $x%$y |
exponentiation | pow($x,$y) |
absolute value | abs($x) |
round up | ceil($x) |
round down | floor($x) |
round to digits | round($x[, $digits] |
cosine | cos($x) |
sine | sin($x) |
tangent | tan($x) |
logarithm | log($x[, $base]) |
minimum | min($x[,$y,...]) |
maximum | max($x[,$y,...]) |
random number | rand([$min,$max]) |
square root | sqrt($x) |
if statement | if (test) {statements;} [else[if (test)] {statements;}] |
print statement | print string; |
variables | $x=number,string,array, or other type of variable |
arrays (brackets are literal) | $i[position] |
strings | "string" or 'string' |
There are many more PHP commands. Many books have been written about PHP and the on-line documentation is very good and includes all the commands.