Module 2- Eli, the Computer Guy, PHP Tutorials 1-6

The purpose of these videos is to get to know a practical overview of PHP from Eli, an IT practinioner. Each assignment begins with Eli doing a theoretical white board explanation. Then, Eli provides a hands on demonstration where he creates, uploads, and runs a program. Finally, Eli provides his final thoughts. Eli has designed these tutorials for beginners which is good for me because I didn't know what PHP was until this class.

To view assignment details click here.

To access Eli's video tutorials over PHP click here.

PHP Programming Part 1 - Introduction to PHP Programming

1.How does Eli describe PHP?

Programming language that makes a website useful, it allows you to interact with data and dynamically write web pages using HTML, CSS and Javascript.

2.Briefly compare and contrast scripted and compiled languages.

Compiled languages use software that when the code is written, it outputs an executable file. Once executed 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 edit the code at anytime).

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 and only certain codes will be available to the user's computer.

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?

Criagslist.com because it is a very useful and popular webpage yet it is really ugly.

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

PHP tells you what you did wrong when coding and running the code. It also tells you in what line it is finding the error.

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

It is a scripting application used for coding, it is like using the Windows notepad but with extra features made to help with coding and it is free to download.

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

You would need a text editor and a web server with PHP interpreter installed.

8. How does Eli describe syntax?

Syntax is how you spell your code and you must be very careful, one mistake and the whole code won't run.

part1

Above you can see a Working example of Eli's notepad ++.php example program.

To view live website click here.

PHP Programming Part 2 - PHP Syntax and Errors

1. In a Linux context, does capitalization matter?

Yes, capitalization makes a difference.

2. What are the basic attributes of PHP syntax?

Quotation marks can help with printing, at the end of the each statement has to be a semicolon telling it to stop reading and go to the next line.

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

How things get closed may cause problems. PHP will complain about a line number in the file, sometimes the error may not be on that given line.

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

Web browser will read HTML. PHP is printing out text.

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?

The web browser can read only a HTML code, and the PHP code is meant for a text viewer. So a HTML tag needs to be used within the PHP code for a web browser to read the print commands accurately. Therefore, the page will not come out at all.


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 comment: // OR #

Multi-line comment: /* */

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

The PHP include function is a function that may include another file's information, the purpose of a function is to reduce repetition. For example, if you create a menu bar instead of rewriting the same menu bar for each of the website, you can call it from the other webpages using the include function.

part3a

part3b

part3c

Above you can see a working example of the 'include' function.

To view live website click here.

PHP Programming Part 4 - Variables in Print in PHP Programming

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

Numbers

Strings

Arrays

2. What naming rules apply to PHP variables?

Variables always start with a dollar sign ($) and must begin with a letter or an underscore. Capitalization still matters.

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

"< b r >" is a client-side break, they can actually see it, on the other hand \n also does a line break but the difference is the break will not show up to the user; is it inly in code view. Basically web browser only interprets HTML code.

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?

When a client visits a website written in PHP, the server reads the PHP code and then processes it according to its scripted directions. It then treats the received code as it would a standard HTML page; making PHP pages very dynamic. On the other hand we have static HTML pages, the reason being because when a request is made, the server merely sends HTML data to web browser, there is no server-side interpretation occurring. You can run HTML pages in your web browser without using a server at all.

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?

Textbook enables the user to type in text. Option box narrows the choices to a list of choices. Radio button's function is similar to the option box except instead of clicking a drop-down list, all of the choices are shown.

part5a

part5b

part5c

part5d

Above you can see a working example of Eli's HTML form and PHP response programs.

To view live website click here.

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.

file_put_contents($file, $email . PHP_EOL, FILE_APPEND);

"file_put_contents" is the function

$file is the file where the data is going to

$email is the data that you are putting into the file

SPACE PERIOD SPACE to give function more commands

PHP_EOL is "end of line" so new data goes to the end of the line on the file

FILE_APPEND appending to a file is adding to the file, therefore instead of deleting the previous email it will add to the list rather than deleting it.

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

CSV file is a type of file. It means Comma Separated Values and this is a standard way of storing data. Because to open data in Excel or similar programs.

part6a

part6b

part6c

part6d

Above you can see a working example of Eli's PHP application that requests the user's email address and links it to it to a file that may be used with excel.

To view live website click here.