Mod 2 Assignments

    Module Two

    To see the assignments for this module click the link above

PHP Programming Part 1: Introduction to PHP Programming

1. How does Eli describe PHP?

PHP is the programming language that makes a website useful. Allows user to interact with data and dynamically write webpages.

2. Briefly compare and contrast scripted and compiled languages.

Compiled languages use software that when the code is written, it outputs an executable file.

After that, the executable file cannot be edited. Scripted languages you upload a text file to a server and then the user can access the file and the software will then process the information and deliver it to the user. You can always use and read a text file where the PHP written at.

3. Briefly explain the difference between client side and server side scripting.

On server side scripting all the process is made at the web server and then output the HTML to the user. On client side the user access the server but all the information gets sent to the users computer, where all the passwords and info of all the users are.

4. What popular website does Eli cite as an example of what you can do with PHP and MySQL? Why did Eli that that this particular site was a good example?

Craigslist.com. Craigslist is exceedingly powerful/effective but its not pretty.

5. What does Eli emphasize as the nice thing about scripted languages such as PHP?

Youre always using the text file and you can always read the source file.

6. What is notepad++? Why would Eli recommend notepad++?

A text editor like notepad that contains a few additional features for writing code.

7. If you want to write and run PHP code, what do you need?

Notepad and a server that has PHP installed.

8. How does Eli describe syntax?

How you spell the commands you are using.

PHP Programming Part 2 : PHP Syntax and Errors

1. In a Linux context, does capitalization matter?

Yes, capitalization does matter.

2. What are the basic attributes of PHP syntax?

Open PHP with <?php and close with ?>. Between the tags, create a command such as print and follow it with quotation marks around what you want outputted. Lastly, end the command with a semicolon.

3. Discuss one of the PHP error handling techniques that Eli presents.

Web browser will print out the error in the file and tell you which line (error may be on the line after or before).

4. What is the difference between printing text and printing HTML?

Web browser reads tags and html coding while PHP prints out text. Thus when working with formatting, use html tags in your php so the browser displays the correct formatting.

5. What happens if you add a PHP script to a HTML page and you don’t change the file type to .php from .html?

It doesnt really matter from the server’s perspective, it only matters from the user’s perspective.

PHP Programming Part 3: Comments and INCLUDE in PHP Programming

1. What are the three ways that you can make comments in PHP?

Single line: // or #

Multi line: /* */

2. What is the PHP include function? Why is it useful?

Grabs information form another file and includes it in the current file. This is useful because you don’t have to rewrite the information.

PHP Programming Part 4: Variables in Print in PHP Programming

1. What are the three types of PHP variables that Eli discusses?

Strings, integers, and arrays

2. What naming rules apply to PHP variables?

Must start with “$” and then with either a letter or underscore. Capitalization matters, PHP is case sensitive.

3. Compare and contrast the html <br> tag in HTML and the \n in PHP.

When the “</br>” tag is used, the break will be seen in the html web browser. When “\n” is used, the break will only be seen in the text source code; not the html browser.

PHP Programming Part 5: HTML Forms and PHP Programming

1. What does it mean when Eli says that HTML creates static pages while PHP creates dynamic pages?

HTML creates the form and all of its objects. If we are going to do anything with the form, we are going to pass it to PHP. PHP writes the information to file or takes information and does something with it.

2. In this exercise, you will use an HTML Textbox, an Option Box, and a Radio Button. What function does each of these input methods provide?

Textbox allows users to enter text strings up to the "size" attribute, Option boxes allow a user to select from a predefined list. If setup correctly the user can utilize the CTRL key to select multiple choices. Radio buttons allow a user to select one choice from a predefined list. The label attribute can be used to make selection more user friendly by allowing the text to be clicked to activate the selection.

Eli's Shirt Size Form

PHP Programming Part 6: Printing to Files with PHP

1. In this example, you use the PHP file_put_contents() function. Briefly describe this function.

Hint: Consult W3Schools or the PHP manual.

This function writes the information, that was given, to a file.

2. What is a CSV file? Why would you want to use one?

Comma separated value file is a spreadsheet format. Can be opened with any spreadsheet program and then be saved as an excel file to be emailed.

Eli's Email Form