The second laboratory is devoted to building competence with basic PHP scripting and developing dynamic documents. Because PHP has only been enabled on the team accounts you need to log onto your team account to do this lab.
Create a document hello-world.php in the
web/htdocs/<your-username>/ directory in
your team account. Make this file world (or other) readable.
Then create a link to this new document from the simple
index.html you created last week.
The difference between your PHP page and the index page being that you
place a simple php echo statement into the PHP document to display
"Hello World".
Example:
Hello WorldNext modify the "hello world" file so that "Hello World"
is printed out multiple times.
Do this by using the PHP for loop construct.
Example:
Hello World Hello World Hello WorldModify the file again so that the "Hello World" line are printed in an alternating choice of font. The font can be bolded/colored/italicised or anything else that you want to choose. See the example below.
Example:
Hello World Hello World Hello World Hello World Hello WorldModify the file again so that the number of times that the "Hello World" to be printed will be held in a variable. Now create a plain html file that contains a form who's action is the php file. The plain html form should have an input in which you can enter a number that specifies the number of times that the "Hello World" line should be printed out.
HINT:To do this the variable name must be the same as the name of the input element in the form.
Modify the above form and php file so that the form accepts a second input which is the name of a person who is to be greeted. Adapt the php script file so that the greeting can be modified by input. If the user enters 5 and Bob as the input data to the form name then "Hello Bob" will output 5 times with each second line in the different color/font.
Example:
Hello Bob Hello Bob Hello Bob Hello Bob Hello BobFinally adjust the php script file again so that the output is placed in a table. The table should have 2 columns. The first column having holds a line number and the second one the greeting.
Example:
| 1 | Hello Bob |
| 2 | Hello Bob |
| 3 | Hello Bob |
| 4 | Hello Bob |
| 5 | Hello Bob |