As mentioned at the lecture, one cannot learn a programming language
just by attending a lecture; it is important to get experienced by
actually working with the language.
Some of these exercises require material that was not covered at the
lecture. As mentioned, there is a manual for the language at www.php.net
Parameters: Expand the Weekplan example on the Arrays slide, such that for each lecture there is a link to a page called week.php sending the correct week number as a parameter to this page in the URL.
File Manipulation: Make a script that takes a number N as
argument and prints out the N'th line of the file brixtofte.txt. If N is negative or larger
than the
number of lines in the file, an error message should be printed. Do
not forget the rules about manipulating with files! (close files
after you, etc)
String Processing: Make a PHP script where a user enters
a text in a form and clicks a 'submit' button. The script should
then show a page, where the number
of occurences of the letter 'e' in the input string is shown.
Arrays: Make a function PrintArray(Array,width,height) that takes a double indexed array and the height and width of this array and arranges it in a table. For instance the result of the call:
Citations: Make a citation index using PHP, both for
getting a quote and for sharing a cool quote with others. The script
should start with a page where the user can choose to get or enter a
quote. Accordingly, the script should either
Print a random quote from the index, or
Show a form, where the user can enter her cool quote and submit
it. The script should then store the quote along with the quotes
already in the index.
The index could be a file where the
different quotes are separated by lines that only contains a
'%'. There is an example here.