This is suitable for people who are just learning programming. This page is a record of what Roger and I were able to accomplish in the first lesson. Charles was there too, but he was fated to drop out because he could not type very fast.
A big question could be, “Why PHP?” Well, PHP has an easy syntax and is extremely useful for web-based programming. It's a great starter, with better syntax than Python. And, why not? PHP has it's own local server, so it's easy for anyone to use. You can just use a text editor. Its oldschool! A great start for the serious. And so, we began.
Run this. What does it do? What is ECHO?
<?php echo "Hello, world!\n"; ?>
Quoting slashes.
<?php echo "echo \"Hello, world!\\n\";"; ?>
Another example.
<?php echo "Hello, my name is Appledog!\n"; ?>
<?php echo "<---- he is Roger!\n"; echo "I am appledog! wheee!\n"; echo "He is Charles! ------>\n"; ?>
We can draw art. Can you make a triangle?
<?php echo "*****\n"; echo "* *\n"; echo "* *\n"; echo "* *\n"; echo "*****\n"; ?>
More art. This is fun! I think, this was a homework question (draw a dinosaur).
<?php echo " __\n"; echo " / _)\n"; echo " _.----._/ /\n"; echo " / /\n"; echo " __/ ( | ( |\n"; echo "/__.-'|_|--|_|\n"; ?>
Oh, this was the homework question. Anyways, note the quoting slashes.
<?php echo " . - ~ ~ ~ - .\n"; echo " .. _ .-~ ~-.\n"; echo " //| \\ `..~ `.\n"; echo " || | } } / \\ \\\n"; echo "(\\ \\\\ \\~^..' | } \\\n"; echo " \\`.-~ o / } | / \\\n"; echo " (__ | / | / `.\n"; echo " `- - ~ ~ -._| /_ - ~ ~ ^| /- _ `.\n"; echo " | / | / ~-. ~- _\n"; echo " |_____| |_____| ~ - . _ _~_-_\n"; ?>
Teacher and Doctor. Here is teacher.php:
<?php $name = readLine("What is your name? "); echo "Hello {$name}!\n"; echo "Your new name is Teacher {$name}.\n"; ?>
and doctor.php:
<?php $name = readLine("What is your name? "); echo "Hello {$name}!\n"; echo "Your new name is Dr. {$name}.\n"; ?>
<?php $name = readLine("What is your name? "); if ($name == "vegetables") { echo "I don't like vegetables!\n"; exit(); } else { echo "Hello {$name}!\n"; echo "Your new name is Mr. {$name}.\n"; } ?>