PHP Programming Part 1: Introduction to PHP Programming
- How does Eli describe PHP?
- Briefly compare and contrast scripted and compiled languages.
- Briefly explain the difference between client side and server side scripting.
- 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?
- What does Eli emphasize as the 'nice' thing about scripted languages such as PHP?
- What is notepad++? Why would Eli recommend notepad++?
- If you want to write and run PHP code, what do you need?
- How does Eli describe syntax? Eli describes syntax as a very important component to writing any type of code. Missing or wrong syntax can make a whole project not work. He uses the semicolon example where if one is not emplaced then the code will not work.
Eli describes PHP as an easy and powerful language that offers many capabilities on creating a website
Scripted and compiled languages are written code that performs a particular task. The difference between the two is that scripted languages is merely just code that cannot do anything unless it is compiled by a software that recognizes the code. Compiled languages are codes that are written and then executed by a particular program.
Client side scripting is when codes are executed then delivered from the web server to the users website. Server side scripting is when written code is made at the web server and when requested is then delivered to the user.
Eli mentions Craigslist as an example of PHP and MySQL because although the website is considered ‘ugly’, Eli says that the website is very efficient.
PHP does not require a fancy program to write code in. All you simply need is a text editor such as notepad or notepad++.
Notepad++ is a text editor program similar to the regular notepad offered by windows. Eli recommends Notepad++ because it has a lot more features that makes coding a lot easier.
To write and run PHP all you need is a text editor filled with your PHP code and a web server that has PHP installed.
PHP Programming Part 2: PHP Syntax and Errors
- In a Linux context, does capitalization matter?
- What are the basic attributes of PHP syntax?
- Discuss one of the PHP error handling techniques that Eli presents
- What is the difference between printing text and printing HTML?
- What happens if you add a PHP script to a HTML page and you don’t change the file type to .php from .html?
Yes capitalization matters in Linux. TEST.php and test.php are two different files.
To treat code as PHP it must be between . ‘Print’ is a basic attribute of PHP that prints out text onto the website. Every PHP code must end with a semicolon ‘;’.
If there is an error in the PHP code, PHP will tell you what line the error is in and what is causing it.
Difference between printing PHP text and printing HTML is that PHP requires tags to specify the browser what is to be printed in PHP or HTML. Without the tags the browser will print it in HTML style
The page will treat the code as text therefore not executing the PHP Scripts.
PHP Programming Part 3: Comments and INCLUDE in PHP Programming
- What are the three ways that you can make comments in PHP?
- What is the PHP include function? Why is it useful?
# Insert Comment , // Insert Comment, //*Insert Comment*/
Include function allows you to take other functions or data from a file and include it into another file. It is useful because it shortens the number of code needed and you can utilize other functions out in the internet as a reference.
PHP Programming Part 4: Variables in Print in PHP Programming
- What are the three types of PHP variables that Eli discusses?
- What naming rules apply to PHP variables?
- Compare and contrast the html tag in HTML and the \n in PHP
Three types of variables that Eli discusses are strings, integers, and arrays.
Variable names in PHP are case sensitive. They also start with a dollar sign $ followed by the name of that variable. Variables can have underscores but variable names cannot start with a number.
Both tags start a new line on the website. In HTML the \n tag will create a new line and will show the new line to the user viewing the page. In PHP the \n will not show a line break to the user but will see the line break in the view page source.
PHP Programming Part 5: HTML Forms and PHP Programming
- What does it mean when Eli says that HTML creates static pages while PHP creates dynamic pages?
- 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?
HTML is considered a static page because it displays whatever you code it with and thats it. PHP creates dynamic pages because it offers a wide variety of functions and methods that allow users to manipulate data that is inputted. Quick examples include mathematics with values in PHP, Arrays that can print out, count, delete, add objects into the array. All can be done in PHP but not in HTML.
HTML Textbox allows users to input text in a textbox. Option box function creates a dropdown menu that users can select the values within that dropdown menu. Radio buttons are buttons that users click and are only allowed to select one value in that radio button.
PHP Programming Part 6: Printing to Files with PHP
- In this example, you use the PHP file_put_contents() function. Briefly describe this function.
- What is a CSV file? Why would you want to use one?
The PHP function file_put_contents allows users to input data into a file that already exists, if not the program will create it for you!
CSV stands for Comma Separated Value and it is a file that takes texts separated by a comma into its own box in a spreadsheet program. Popular csv program is Microsoft Excel. You would want to use csv files because it has the power to turn data into information that are neat and organized spreadsheet boxes.
