What is PHP? ?

What is PHP?


PHP, which stands for "Hypertext Preprocessor", is a server-side,
HTML embedded scripting language used to create dynamic Web pages. Much of its syntax is borrowed
from C, Java and Perl with some unique features thrown in. The goal of the language is to allow Web
developers to write dynamically generated pages quickly.


In an HTML page, PHP code is enclosed within special PHP tags. When a visitor opens the page,
the server processes the PHP code and then sends the output (not the PHP code itself) to the
visitor's browser. It means that, unlike JavaScript,
you don't have to worry that someone can steal your PHP script.


PHP offers excellent connectivity to many databases including MySQL, Informix, Oracle, Sybase,
Solid, PostgreSQL, and Generic ODBC. The popular PHP-MySQL combination (both are open-source products)
is available on almost every UNIX host. Being web-oriented, PHP also contains all the functions
to do things on the Internet - connecting to remote servers, checking email via POP3 or IMAP,
url encoding, setting cookies, redirecting, etc.


What do PHP code look like?


PHP is a rather simple language. Much of its syntax is borrowed from C except for dealing with
the types of variables. You don't need to think of the types of variables at all - you just
work with their values, not their types. And you don't have to declare variables before you use them.


Basic Syntax


  • File name:

    You should save your file with the extension .php (earlier versions used the extensions .php3 and .phtml).


  • Comments:

    // This comment extends to the end of the line.

    /* This is

    a multi-line

    comment
    */

  • Escaping from HTML:

    A PHP code block starts with "<?php" and ends with "?>". A PHP code block can be
    placed anywhere in the HTML document.


  • Instruction separation:

    Each separate instruction must end with a semicolon. The PHP closing tag (?>) also implies
    the end of the instruction.


Here's a small PHP example...



<html>

<head><title>Example</title></head>


<body>

<h1><?php echo "Hello World"; ?></h1>

<?php

$txt = "This is my first PHP script";

/* This line creates the variable $txt and gives it the initial value. Variables in PHP are represented by
a dollar sign followed by the name of the variable. The variable name is case-sensitive.
*/



echo $txt;


?>

</body>

</html>