Homework: Read the pages "Introduction, Syntax, Variables, Echo, Operators, Comments, Forms, Functions" on the PHP Tutorial
PHP pages have the extension ".php"
Variables must begin with a $-sign in PHP! Moreover, no spaces are allowed inside a variable name.
Every statement in PHP must be ended with a semicolon.
echo: With the code echo "<b>Good morning, world </b>" ; you write the text "Good morning, world" in bold face on the page. Avoid quotation marks inside the string---use single quotation mark ', or, if you must use ", use \". You echo variables without quotation marks, like in echo $day;, but if you have to output both strings and variable, you concatenate using the period ., like in echo "today is" . $day;. If everything should be bold, you write echo "<b>today is" . $day . "<b>";
Mostly PHP is used to evaluate information submitted in forms, and respond accordingly. Your form needs an action attribute and a method attribute. "action", like in action="Filename.php" tells where the data is send when a type="submit" button is hit. We will usually use method="post" (rather than method="get"). When sending the button by hitting the type="submit" button, the names of all form elements become PHP variables, with a $ in front of them, which you cann access at the page where the information is send to.
The function for opening or creating) functions is $PointerName = fopen($FileName, 'w');, where $FileName is of course the name of the file you want to create (including extension, like "txt"), and the second parameter is
Every open text file has a pointer pointing (which we named "$PointerName" above) to a certain character in the file. If reading and writing should be allowed, you use 'r+' if the pointer startes at beginning, 'w+' if all existing data should be erased, and 'a+' if pointer startes at the end.
When you are done working with a file, you should close it using the function fclose($PointerName);
You write into an open file using the fputs function, as in fputs($PointerName,"Some text string");. You would start a new line with /n. You read with the "fgets" function, as in fgets($PointerName,5);. In this case you would read 5 byte, starting from the present location of the pointer, of course. You would rewind the pointer using the function rewind($PointerName);.
Erich Prisner, September 2003