Tedd's Examples
The following are links to examples created for this class.
The examples shown here are to show you how PHP code works. Your assignments for each of these topics will be to create example(s) that demonstrate your understanding the concepts.
In all your examples, please remove my name (or 'you' or 'yours') and replace it with your name. In addition, make certain your code works like mine and has links back to your examples page. The purpose of this 'cut/paste' is to allow you to see the code run. You should examine the code to see how it works and is used.
When the assignment asks you for a creative example using the topic of the week, it is up to you to read and review those examples to see how they work and to create an example that also demonstrates how the topic works. For example, if the topic of the week is strings, then a creative example might be to review the PHP manual describing string functions and then use one or more, to alter a string. You may also want to review the Various String Functions link on the right-side of this page.
End of Semester (Dec 16, 2024): -5 Days Approx: -1 Weeks
top
Week 1. IDE setup
Chapter 1
- PHP Storm < Your IDE.
- Installing PHP Storm and getting your IDE to connect to the LCC Server.
- PHP Logon set-up using PHPStorm
Your first Assignment (Week 1) is to take a screenshot of your
connection to the LCC Server and submit that to correct dropbox.
The above link shows you how to connect PHPStorm to the LCC server.
top
Week 2. Hello World (Includes)
Chapter 2
- Hello World • Do this
- Hello World with show code • Do this
- Hello World with include • Do this
- Do Your Main Page with above Examples
- Menu Includes Example
- Show How Links Work
Your Assignment is to get "Your Main Page with Examples" web page up and running using "header" and
"footer" includes. From there, do the above "• Do This" projects and link those projects to your
work.
The purpose of this exercise is to make your Example web page easy to add assignments and keep
assignments
in order for easy viewing and grading.
top
Week 3. HTML Forms
Chapter 9
- $_GET Form • Do this
- $_POST Form • Do this
- Simple "Sticky" Form • Do this
- All In One Form • Do this
- Simple Dropdown Form
- $_REQUEST Example
- Form - NOT Secure
- Form - Secure
- Redirect
The above shows how to set up a form to gather information from a user via GET and POST super globals. The REQUEST example shows you why you should NOT to use this super global to gather any data I'll explain im class).
The "Simple Sticky Form" demonstrates how to pass the values a user provides to re-populate the form. Note: This example passes the values via the POST super global. It works for the GET super global in same fashion.
The "All in One Form" shows many of the HTML controls that you may use to get a user's input to a set of values. For example, instead of asking for a "true" or "false" from a user, you can have them click a checkbox. Also, instead of asking a use to pick "one of something", you can ask via a set of radio buttons. These controls show you how to gather users input.
The Simple Dropdown Form shows how to use one of the controls shown in the "All in One Form", namely the Dropdown menu.
The Forms - "Form - NOT Secure" and "Form - Secure" are examples that show how JavaScript code can be blocked. You do not want a bad actor to use your form to launch a JavaScript routine (like a mass emailing of spam).
The "Redirect Form" shows how a simple radio button can redirect a Browser to another Website or code.
Your assignment is to demonstrate your command of PHP to provide these controls to the user and how to gather information from the user.
top
Week 4. Variables - Data-types - Expressions
Chapter 3
- Book's Example (page 49) • Do this
- User's value for Calculation • Do this
The above examples show how you can use variables in calculation and be able to pass those values from one form to another form.
• Do thisYour assignment is to demonstrate your command of using PHP variables to do calculations. You should use a form to get data from a user and then present the results via a calculation. What type calculation is up to you, just demonstrate you know how to use variables.
top
Week 5. Decisions and Loops
Chapter 4
- Decision Examples • Do this
- Loops • Do this
The above examples show how decisions and loops are generated in PHP.
• Do thisYour assignment is to demonstrate your command of decisions and loops. I suggest you use a form to gather values and then preform a series of decisions and loops to present something of value.
Please review the examples past students have provided (right side of this page).
top
Week 6. Strings
Chapter 5
- Strings • Do this
- Strings Revisited • Do this
- String Replace • Do this
- More String Stuff ( file_get_contents() ) • Do this
The above examples show how strings are used in PHP.
• Do thisYour assignment is to demonstrate your command of strings. I suggest you use a form to gather values and then preform a series of string operations to present your understanding of string manipulations.
Please review the examples past students have provided (right side of this page).
top
Week 7. Arrays
Chapter 6
- Arrays • Do this
- Arrays Revisited • Do this
- $_GLOBAL Array Example • Do this
- $_SERVER Array Example • Do this
The above examples show how arrays are defined and used in PHP.
The GLOBAL array example show how globals can be used in PHP.
The SERVER array example shows the contents of a SERVER array. Sometimes it is important to obtain data about the user's visit to be used in your script.
• Do this
Your assignment is to demonstrate your command of arrays. I suggest you use a form
to gather values and store those values in an arrays. Then do array manipulations
to show both your command at using arrays and your investigation into the vast
assortment of PHP array functions at your command.
Again, present your findings in a clear and consistent manner for grading.
top
Week 8. Functions
Chapter 7
The above examples show how to define and use functions in PHP.
• Do this
Your assignment is to demonstrate your command of functions. I suggest you
create three functions
(or more) to do operations, such as a function that take a value and performs a
calculation, or a
function that does text manipulation and present the results, or a function that
returns an HTML change.
What your functions do is up to you -- use your imagination.
Again, show your examples in a clear and consistent manner to demonstrate how
you create and use functions.
top
Week 9. Preserve State
Chapter 10
- Query String via GET • Do this
- Query String via POST • Do this
- COOKIE • Do this
- Simple SESSION • Do this
- SESSION Array
The above examples show how to pass variables between pages.
As you know, from previous assignments, you can pass variables between pages using GET and POST.
You can also store values on a web page using COOKIES.
Please demonstrate an example of you using COOKIES.
Often the number of variables make using GET, POST, and COOKIES make the process too complicated to pass a significant number and organization of those values impractical. As such, you have the option of using SESSIONS. The SESSION examples show how to set up a SESSION and how to use it to pass variables between pages.
• Do thisYour assignment is to demonstrate your command of using SESSIONS. Show your example in a clear and consistent manner to demonstrate how you populate varables using SESSIONS.
top
Week 10. Files and Directories
Chapter 11
- Hit Counter • Do this
- Read File • Do this
- Read Write File
- Replace Strings in a File
- Inspect File
The above examples show how to read and write variables in files.
The Inspect file is for your viewing only showing how you can not only read the contents of a file but dig deeper into a file. You do NOT need to reproduce this script.
• Do thisYour assignment is simply to read and write to a text file. Remember to put a file entitled 'text.txt' in your doc directory else the "Read File" example won't work.
top
Week 11. MySQL 1 (Introduction)
Chapter 12
- Select Database Records • Do this
- Search Table • Do this
- Show all Clients located in CA. • Do this
Please see me for your logon ID and password.
The above examples show how to retrieve and search records from a Database.
• Do this
Your assignment is simply to duplicate the two examples above AND to write a PHP script to pull all
records from the client's table whose address is in the state of California (i.e., CA).
NOTE: Exposing your configuration file and showing your logon id and password is prohibited.
Failure to follow this requirement will result in a zero for this assignment with no possibility for
re-grading.
top
Week 12. MySQL 2 (Retrieving Data)
Chapters 13-14
• Do this
1. You do not have to duplicate the code given above. It is there to show you how to code this.
2. Your assignment is to add your name to the CRUD example. Please do not delete other
student's names.
3. Your assignment is to use the Relational Database Demo to add your
name to the Authors Table and add three books to the Books Table. Then assign your
name as an author to the three books you added. Again, please do not delete other
student's work.
top
Week 13. Date & Time, Email and Encrypt
Chapter 16
- String to Time • Do this
- Time & Date • Do this
- Micro Time
- Encrypt Form • Do this
- Decrypt Form • Do this
- Standard email • Do this
- SMS DEMO
Your assignment is to do the above "• Do this"
Additionally, I would like you to use the SMS DEMO with your own cell phone.
Select your Carrier and submit a message to yourself.
Submit a text file to the dropbox telling of your attempt.
Did it work and which Carrier did you use?
top
Week 14. Graphics 1
Chapter 17
- Draw a Polygon • Do this
- Draw Circles • Do this
- Draw Complicated Circles • Do this
- Draw Complex Functions • Do this
- Draw Rotated Text • Do this
Your assignment is to do the above "• Do this"
And, create a drawing using elements provided above.
top
Week 15. Graphics 2
Chapter 17
- Create Watermark • Do this
- Draw Text on an Image • Do this
- Change Picture's Brightness • Do this
- Change Picture's Width • Do this
- PDF Demo
Your assignment is to do TWO of the above "• Do this" with your own images.
top
Week 16. Regular Expressions (Regex)
Chapter 18
The following are examples to help you understand how to use Regex.
- Regular Expression Demo
- Pulling links from the CITW185 index page
- Regular Expression Form
- Parsing HTML to find links
- Parsing re REGEXR Demo
- The Regular Expression Problem • Do this
Your assignment is to do the above "• Do this".
The Examples above should provide insight as how to solve The
Regular Expression Problem.