Linux, Apache, MySQL and PHP are collectively known as the LAMP software bundle and power most of the websites of the planet.
Linux is the most popular operating system on the Internet today. It’s powerful, reliable and, most of the time, free. Linux powers all of Google’s as well as Amazon’s infrastructure for instance. Apache is the most popular web server used. According to Netcraft, Apache powers 60% of all websites in January 2011. MySQL is the most popular relational database used in the world.
And, finally, PHP is also very popular. WordPress, Drupal and Joomla are written in PHP and, of course, Wikipedia and Facebook are too.
In other words, PHP (together with Linux, Apache and MySQL) power a large part of the Internet.
Exercises
We wish to automate the buying of auto parts online. We will proceed in steps until we get a reasonable web application. Write simple PHP scripts to do the following:
- Display static text (typically, “HelloWorld”) when a form is submitted
- Display dynamic text (using the date() function) when a form is submitted
- Accessing form variables using superglobals $_GET, $_POST and/or $_REQUEST
- Display form variables using string interpolation
- Use HEREDOCS
- Use variables (integer, float, string, boolean, array, object), constants, operators (string, arithmetic, comparison, logical, error suppression @, execution `) to do calculations
- Use numberformat to format currencies appropriately
- Use if statements to test the existence of form variables and to make the script work gracefully if form variables do not exist or contain non valid data
- Use elseif to offer discounts depending on quantity of products ordered
- Use switch to display appropriate messages depending on how the customer has discovered the website
- Use loops (i.e. while and/or for) to display shipping rates which depend on distance travelled
- Store orders in a file and write a script to display all past orders
- Use arrays to summarise all past orders
- Use foreach and associative arrays to display help pages on various topics (shipping, warranty, contact)
- Use functions and array_walk to simplify the display of help pages
Leave a Reply