Friday, May 9, 2008
PHP Files, Syntax, and Coding Basics...




PHP and MySQL Tutorials
PHP Files, Syntax, and Coding Basics...

Introduction to PHP and Dynamic Websites...

Learn how to configure Apache, PHP, MySQL & PHPMyAdmin...

Introduction to PHP and Dynamic Websites:

It's time to face it: The sun is setting on the age of static websites. Users have come to expect sites that are updated frequently, sites that allow them to purchase products online, and sites that make them feel like they're in control. With the huge increase in e-Commerce and internet useage, HTML can't do the job on it's own anymore.

So Why PHP?

  • PHP is easy to learn: You don't need to be a Rocket Scientist to understand PHP. In fact, I had mastered the basics of the language by the time I was 14! All you need is a little dedication and a desire to learn.

  • With PHP you can build dynamic web applications FAST: The enormous flexability of PHP allows you to create professional web applications quickly and efficiently. In the subsequent lessons you are going to amaze yourself with what you can do.

  • PHP comes with an open-source community: This means that there are hundreds and thousands of articles, code repositories, and help forums that you can tap into... for free!

  • PHP is the most common scripting language: Have you ever tried to find a hosting company that supports ASP or Python? It's possible, but it's a pain in the neck. You won't have to deal with that, since nearly every Web Server has PHP installed. If they don't, it's an excellent hint that they're "behind the times" and you probably shouldn't host with them.

What is PHP?

According to the PHP website - www.php.net - PHP is "a widely-used general-purpose scripting language that is especially suited for Web development and can be embedded into HTML."

Quite a mouthful, eh? Let's break it down:

"PHP is a widely-used general purpose scripting language..."
This means that PHP is a server-side language which, unlike JavaScript or HTML, is parsed by the server before being delivered to the browser. The diagram below will help you better understand how a PHP script works.

This diagram shows how a PHP script works.

In the diagram above a user requests a page (for example, www.yoursite.com/index.php). The request is sent to the server where the PHP code is parsed. The final step is to send it back to the browser as plain HTML.

"...that is especially suited for Web development..."
This next part is rather self-explanatory. It means that PHP was especially designed to create web applications, which is good news for us!

"...and can be embedded into HTML."
The last part might sound a bit confusing at first. What it means is that PHP code can be interspersed within HTML code, like this:

Example 1.1:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
   <meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
   <title>PHP code can be embedded within HTML code!</title>
</head>
<body>

<?php // PHP code ?>

</body>
</html>

This feature makes it very easy for new programmers to develop their scripts and add them to pre-existing sites and templates.

The Power of PHP

Many people underestimate the sheer magnitude of applications that can be built using PHP. Here are just a few that I have created:

  • Secure Login Authentication
  • Form Processors
  • Photo Galleries
  • Mailing Lists
  • Polls
  • Online Testing and Quizzes
  • Article and News Applications
  • Real Estate Listing Managers
  • Content Management Systems
  • Website Anayltics and Visitor Statistics
  • e-Commerce solutions (Shopping Carts, Payment Integration, etc.)
  • ...just to name a few.
« Return to the Lessons Page | Continue to Lesson 2 »