PHP Lesson 1 – An Introduction
Posted by Jon on June 10th, 2010

PHP is an open source server-side scripting language. It has become very popular in recent years because of its versatility and because it’s very easy to learn.  You can be writing PHP scripts 5 minutes after you are introduced to the language. As I said, it is a server-side scripting language.  This means that anything you write in PHP code will not be seen by anyone browsing the internet.  The code you write sits on the server, and the server interprets it.  After it reads your code, it outputs to the world the results of your code.

For instance, say you wanted to have a copyright notification at the bottom of your website.  You could write something like this:

  1. <p>copyright 2007-2011</p>

Writing this makes a static date show up on the bottom of your page.  But what happens when 2012 rolls around?  You have to edit the code and change the date.  PHP allows you to get around this.  By using a simple PHP date function you can make the date change every year to automatically be the current year!  The new code would look like this:

  1. <p>copyright 2007- <?php echo date('Y'); ?></p>

This simple function outputs the current year to the page in place of our static data (“2010”).  You can begin to see how useful it is to use a language like this in conjunction with the HTML and CSS that you already know.

  1. <?php
  2. do_something();
  3. ?>

One Response

09.23.11

I’m new to PHP and am working with databases. How would I pull data from a database using PHP?

Leave Your Response

* Name, Email, Comment are Required