Google Answers Logo
View Question
 
Q: PHP Exercises and Syllabus ( No Answer,   0 Comments )
Question  
Subject: PHP Exercises and Syllabus
Category: Computers > Programming
Asked by: willshiz-ga
List Price: $10.00
Posted: 13 Mar 2004 06:27 PST
Expires: 12 Apr 2004 07:27 PDT
Question ID: 316311
Hi, I am looking for syllabae posted online that contain exercises to
do in a very basic PHP programming course. I am teaching a course and
would like to find some nice easy exercises for the students. The
students will start our with HTML so it is really pretty basic.

Request for Question Clarification by tar_heel_v-ga on 13 Mar 2004 08:13 PST
Is there a particular text book you are using?

Request for Question Clarification by tar_heel_v-ga on 13 Mar 2004 08:16 PST
Would something like this be acceptable:

Weekly Assignments
Week 1: Introduction 
Week 2: PHP Basics 
Week 3: Reading and Writing Content 
Week 4: Control Structures 
Week 5: Strings 
Week 6: Regular Expressions 
Week 7: File Handling 
Week 8: Network Functions 
Week 9: E-Commerce 
Week 10: Session Control 
Week 11: Beginning MySQL 
Week 12: PHP and MySQL 
Week 13: Catch Up 
Week 14: Wrap-up 
Week 15: Final Projects 
Week 16: Final Projects 

Each week broken down like this:
Week 1: Introduction -- 19 Jan Welcome to the first week of classes.
There are no classes this Monday.

Topics/Readings
Introduction - (lecture notes) 
Please Review the FAQ - (Frequently Asked Questions) 
Unix Review - (lecture notes) 
PHP Intro - (PHP and MySQL, Chapter 1) 
resource - (PHP.net - http://www.php.net/ - The official PHP resource site.) 
resource - (Apache - http://www.apache.org/ - The world's most popular
Web server.)
resource - (MySQL - http://www.mysql.com/ - The world's most popular
open source database)
Lectures
Introductory Materials 
Unix Review 
PHP History 
Uses of PHP 
Assignments
 Homework 1
Homework 1B: Using FTP
Homework 1C: Using Blackboard

The homework assignments and some of the lecture notes would also be available

Clarification of Question by willshiz-ga on 14 Mar 2004 03:55 PST
Hi, thanks for the info. I am using a basic book called PHP for the
World Wide Web 2nd Edition by Larry Ullman.
The syllabus you gave was interesting but for one thing it may be a
bit advanced because it includes a discussion of Unix. That is not bad
but it does seem that it is a bit advanced for my students. Also, I am
really looking for exercises and problems for the students. The book I
am using has none.
Thank you.

Request for Question Clarification by tar_heel_v-ga on 14 Mar 2004 16:42 PST
Here is a sample exercise from week 2:

Hello WorldThe objective of this exercise is to develop a basic
familiarity with using PHP in the context of Web documents.

This should be a really easy assignment. If you have problems with it,
let me know because the homework will rapidly get much more
challenging. By the end of the semester, you should be able to take a
barebones description of the intended assignment, think through the
details and potential difficulties on your own, and produce a
solution.

Step 1: Hello World
Open up Notepad (or your text/code editor of choice) on your computer
and type out the following code (almost) exactly as it appears. Which
is to say type it as it appears except where it tells you to insert
your name at that point, or where it tells you that you will be adding
more content further on, etc.

<THERE IS PHP CODE HERE>

Now save it in your homepage directory on your H:/ drive with the name
hello.php. Make sure neither you nor the computer add an additional
.txt suffix to the end of the file name.

If you are working at home, you will need PHP to test it or will have
to uplaod it to the campus servers first.

Step 2: Adding some PHP
Okay, so we have the XHTML shell and now need to add the PHP. PHP gets
included inside processing directives.

processing directive: a command directly addressed to the program
processing the code to give it instructions on how to do so
All processing directives begin with an open bracket and a question
mark, and end with a question mark and closing bracket. Within the
brackets go the name of the application being passed instructions to
and the instructions to be passed. If the name of the application is
included, it must come immediately after the question mark, just like
and HTML or XML tag.

<?appname some instructions ?>

We already have one example of this in the XML version declaration
statement above.

The XML version declaration also used the processing directive format.
However, the campus servers currently have a PHP system variable
called short_open_tag set to "on". This means that the PHP parser with
treat any statement starting with an open bracket and a question mark
as a PHP statement. Therefore, you cannot have any XML processing
directives in the code.

What we are going to do is add a piece of script that reads the
information from the form when loading the page.

Wait, you may ask, if it processes the information before sending the
page, how can it process information the user hasn't entered yet? The
answer is, it can't. But it can look at the information send to it
when someone fills in the form field and then clicks submit, which if
you look at the action attribute value for the form, reloads the same
page.

Enter the following code right after the opening heading in the document. 
<h2>My First PHP Generated Document</h2>

<?php
if ($HTTP_POST_VARS["namefld"]) {
  echo "<p>Hello, ".$HTTP_POST_VARS["namefld"]."!";
  echo "</p>\n";
  }
?>

Save the document again. 
Step 3: Look at It
Open up Internet Explorer or Netscape Navigator. In the address bar
enter the address:
http://academ.hvcc.edu/~YourID/hello.php 
and press Enter. 

If you are working from home, then use the path appropriate for you
home server setup.

If your Web page does not show up, check to see if you can figure out
what is wrong. Otherwise ask for help.

Put your name into the name field and click the Click Me! button. 

The document should be rewritten with the greeting from the PHP code. 

First, let's finish the directions, then I will explain what happened.

When you are done with this assignment, send me an e-mail with a link
to the page you have written. The address should be
http://academ.hvcc.edu/~YourID/hello.php 

Explanation
What happened in this exercise?
When we submit our form it submits the information from the form back
to the server. If you remember how forms work, they send a collection
of name value pairs involving the name attribute of the field and the
value entered into or assigned to the field.

The PHP parser recieves the information from the form formatted into
an array. If we use method="post" then the array will be named
$HTTP_POST_VARS or $_POST for short. If we use method="get", then the
array will be named $HTTP_GET_VARS or $_GET. Here we used "post."

The index values for the array are the names of the fields in the
form. Our field was named "namefld", therefore, the array element we
are looking for is $HTTP_POST_VARS["namefld"]. We simply check to see
if it exists, and if it does, we write its value out as part of a text
string. The period, or dot, acts as a string concatenation operator in
PHP. The echo command is used to write output back to the document
being processed with PHP.

By the way, be careful with single and double quotes in PHP. They do
different things.

Each section has assignements.  The text being used is "PHP and MySQL
Web Development, 2nd Edition. by Luke Welling, Laura Thompson.
Developer's Library/Sams Publishing, 2003. ISBN: 0-672-32525-X

Regarding Unix, it appears there is only a review and the rest of the
course doesn't focus on it.
Answer  
There is no answer at this time.

Comments  
There are no comments at this time.

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy