Class 7
Client-side Quiz
Discussions
- Introduction to PHP
- The main uses of PHP: templating and business logic
- PHP variables, functions, and arrays
- Some notes on using strings in PHP
- Introduction to arrays in PHP
- A note of caution about a conflict between the “xml” tag and PHP “short tags”
BASIC SYNTAX EXAMPLES
Note that if you view the page source of any PHP script in your web browser, you will not see any PHP code… this is the nature of server-side scripting – it is processed by the server and then stripped out of the page before that page is sent to the browser. So you will need to download these example files from the server using a file transfer program in order to view the PHP code in a text editor.
- Defining string variables using single quotes, double quotes, and heredoc syntax
- If/else/elseif statements in PHP
- for loop
- while loop
- function example
- simple array
- associative array
ECHO EXAMPLES
- simple echo command
- echoing out a variable created with heredoc syntax
- using the print command with heredoc syntax
Templatizing Examples
INCLUDE FILES
REDIRECTING TO ANOTHER PAGE
GETTING INFORMATION ABOUT YOUR PHP SERVER SETUP
STRING MANIPULATION
In-Class Assignment
- Multidimensional Array Templatizing Assignment #1
- An example of how to structure your PHP code for this assignment
- Note: Remember that you will never see the PHP code by viewing these example files in the web browser.
- You must download these files via SFTP and open them in a text editor in order to view the code inside.
Homework
- Complete the in-class assignment
- Read through all the PHP tutorials on the Tizag site.
- And here’s an optional advanced homework assignment (and a hint for working with text files)