<?PHP indicates the start of a section of PHP code,
?> indicates the end of a section of PHP code.
Anything not between <?PHP and ?> is HTML code and anything between them IS PHP code.
-------------------------------------------------------------------
The echo function is PHP code which is used to display HTML code. This is useful for when you need to use the HTML code to do something rather than just display it. I.E a button.
The echo function uses either ' or " to indicate the code between it. Example: echo"Hello"; or echo'Hello';. The ; is to end a statement in PHP, without it the code will give errors.
--------------------------------------------------------------------
A variable is a memory location which can change whilst the code is running, and be used to store data and then display it. These are defined by simply typing $ then the name of the variable then = then the value.
Example, $variable = "Variable";. Defining a variable is also a statement so it needs a ; at the end. Now the variable $variable contains "Variable" inside it, it can then be displayed using "echo $variable;".
---------------------------------------------------------------------
If statements can be useful in PHP, it is where a set of code is only executed when a condition is met with the brackets of the statement. This is started using "IF (condition) {Code to be executed};".
You can also add an else so if the condition is not met it does "ELSE {code to be exectuted};".
Since ELSE is part of the IF statement the ; comes after the else.
You can also use "ELSE IF (condition) {code to be executed};" This will run if the IF condition is not met but the ELSE IF condition is met.
Example, IF ($variable=="Variable") {$variable="True";} ELSE IF ($variable=="Variable") {$variable="True";} ELSE {$variable="?";}; This code will check if $variable is spelt correctly and make it contain "True" or if it is spelt incorrectly $variable stores "False".
---------------------------------------------------------------------
MORE COMING SOON!