1. Technology
You can opt-out at any time. Please refer to our privacy policy for contact information.

Learn PHP - A Beginner's Guide to PHP Programing


1 of 9

Basic PHP Syntax
PHP is a server side scripting language used on the Internet to create dynamic web pages. It is often coupled with MySQL, a relational database server that can store the information and variables the PHP files may use. Together they can create everything from the simplest web site to a full blown business web site, an interactive web forum, or even an online role playing game.

Learn more about PHP.

Before we can do the big fancy stuff we must first learn the basics from which we build on.

  1. Start by creating a blank file using any program that can save in plain text format.

  2. Save your file as a .PHP file, for example mypage.php. Saving a page with the .php extension tells your server that it will need to execute the PHP code.

  3. Enter the statement <?php to let the server know that there is PHP code coming up.

  4. After this we would enter the body of our PHP program.

  5. Enter the statement ?> to let the browser know the PHP code is done.

Every section of PHP code starts and ends by turning on and off PHP tags to let the server know that it needs to execute the PHP in between them. Here is an example:

<?php //on


//off ?>

Everything between the <?php and ?> is read as PHP code. The <?php statement can also be phrased as simply <? if desired. Anything outside of these PHP tags is read as HTML, so you can easily switch between PHP and HTML as needed. This will come in handy later in our lessons.

Related Video
Basic PHP Syntax
  1. About.com
  2. Technology
  3. PHP / MySQL
  4. Learn PHP
  5. A Beginner's Guide to PHP Programing

©2014 About.com. All rights reserved.