Knowledge7

The Linux and Mobile Solution Provider

  • About
  • Training
  • Services
  • Clients
  • In the news
  • Blog
  • Contact Us
You are here: Home / Topic / PHP and the Web

PHP and the Web

This topic is part of our Object-Oriented Programming in PHP training

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:

  1. Display static text (typically, “HelloWorld”) when a form is submitted
  2. Display dynamic text (using the date() function) when a form is submitted
  3. Accessing form variables using superglobals $_GET, $_POST and/or $_REQUEST
  4. Display form variables using string interpolation
  5. Use HEREDOCS
  6. Use variables (integer, float, string, boolean, array, object), constants, operators (string, arithmetic, comparison, logical, error suppression @, execution `) to do calculations
  7. Use numberformat to format currencies appropriately
  8. 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
  9. Use elseif to offer discounts depending on quantity of products ordered
  10. Use switch to display appropriate messages depending on how the customer has discovered the website
  11. Use loops (i.e. while and/or for) to display shipping rates which depend on distance travelled
  12. Store orders in a file and write a script to display all past orders
  13. Use arrays to summarise all past orders
  14. Use foreach and associative arrays to display help pages on various topics (shipping, warranty, contact)
  15. Use functions and array_walk to simplify the display of help pages
This topic is part of our Object-Oriented Programming in PHP training

Our forthcoming training courses

  • No training courses are scheduled.

Leave a Reply

Your email address will not be published. Required fields are marked *

Looking for something?

Want to know more?

Get our newsletter

Discover the latest news, tips and tricks on Linux, the Web and Mobile technologies every week for FREE

This work is licensed by Knowledge7 under an Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0) license.