Minggu, 29 September 2013

PHP PROGRAMMING

 


1. PHP Definition
 

PHP is a scripting language that is often embedded into HTML to add functions.
HTML alone can't do. PHP allows you to collect, process and utilize data to create a desired output. In short, it let's you interact with your pages. PHP is able to preform a number of tasks including printing data, making numeric calculations (such as addition or multiplication), making comparisons (which is bigger, are they equal, etc) and making simple boolean choices. From this you can create more complex loops and functions to make your page generate more specialized data.

2. PHP Basic

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
//and
//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.