In PHP we can enter comments in our code (which is strongly advised to read your code elsewhere), by following ways:
/ / Everything that follows these two slashes is the comment will not be interpreted by the server
/ * All that is between these characters is the comment will not be interpreted by the server * /
It may also introduce php code in HTML, and yes! On the previous script hello world, so I could add a title to my page (for example) by writing:
In this case php include in html, the file is named with an extension. Php forever.
<title> my page title </ title>
echo "hello world";
Php variables, as in any programming language, are objects that can contain data. These data can be changed at will during the execution of a script. They are essential for programming!
Php variables can be named with letters, numbers, and the _, but the name can not start with a digit. These names are sensitive and they always (well in php) $ dollar sign in front. Example: $ nom_variable variable is a valid, but $ 89variable is not valid name.
PHP has another advantage with variables: there is no need to define or to typer. You can write:
$ pi = 3.14; / / php will while $ pi is a real point
$ pi_arrondi = 3 / / php $ pi_arrondi know that is an integer
$ sigle_html = "hypertext markup language"; / / here is a string
Here is a sample script php, performing calculations with variables, which should be fairly simple to understand:
Finally, there are variables one particularly because they can keep more data: the tables.
largeur_rectangle = $ 5;
$ longueur_rectangle = 10;
$ surface_rectangle = 5 * 10;
echo "The surface of the rectangle is equal to $ surface_rectangle";
Thus, to illustrate the tables, if I need a variable containing all the days of the week to work with them days later in the script, I may define a table like this:
I can also write (which will return to the same thing):
$ jours_semaine  = "Monday";
$ jours_semaine  = "Tuesday";
$ jours_semaine  = "Wednesday";
$ jours_semaine  = "Thursday";
$ jours_semaine  = "Friday";
$ jours_semaine  = "Saturday";
$ jours_semaine  = "Sunday";
One wonders at first sight, what can these arrays, but no worries, you will know quickly enough in handling PHP in practice.
$ jours_semaine = array ( "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday");