Intro to Php





PHP is a server-side scripting language designed specifically  for the web. Within an HTML page, you can embed PHP code that will be executed each time the page is visited. Your PHP code is interpreted at the web server and generates HTML or other output that the visitor will see.
PHP was introduced in 1994. As of November 2007, it was installed on more than 21 million domains worldwide, and this number is growing rapidly. You can see the current number at http://www.php.net/usage.php
PHP is an Open Source project. PHP originally stood for Personal Home Page and now stands for PHP Hypertext Preprocessor.

A Simple PHP Script

Output : Hello Ogbugbu!

Beginning and Ending a Block of PHP Statements

When writing PHP, you need to inform the PHP engine that you want it to execute your commands. If you don’t do this, the code you write will be mistaken for HTML and will be output to the browser. You can designate your code as PHPwith special tags that mark the beginning and end of PHP code blocks.
shows four such PHP delimiter tags.

PHP Start and End Tags
Tag Style Start Tag End Tag
Standard tags <?php ?>
Short tags <? ?>
ASP tags <% %>
Script tags <SCRIPT LANGUAGE=”php”> </SCRIPT>

Example 1  :

Example 2 :

Example 3 :

Example 4 :

You can also put single lines of code in PHP on the same line as the PHP start and end tags:


Combining HTML and PHP
A PHP Script Incorporated into HTML