Introduction to PHP

Hello Guys Welcome to Coding Gurus Online Portal ...!

Lets give a kick start to a Dynamic Language PHP. Untill now we have learnt HTML which will be use full only to create static page where only a user can see the data posted by the website administrator but user cannot contact or communicate him through the website.

Now using this dynamic language PHP we can create web pages where a two way communication can be done from client to server in form of form submission ,comments etc.

Lets get started now with PHP. PHP is a server scripting language, and is a powerful tool for making dynamic and interactive Web pages quickly. PHP is a widely-used Languge , free and efficient

Getting started:

Type the following code in a text editor and save it as "myfirstpage.php"

<!DOCTYPE html>

echo "My first PHP scripting!";

Basic Syntax in PHP

A PHP script starts with <?php and ends with ?> :

The PHP code goes here
The default file extension for PHP files is .php. A PHP file normally contains HTML tags, and some PHP scripting code.

In order to observe the output of the preceding code you need to first understand this:

Php is a server side language. Thus PHP script is executed on the server, and the plain HTML result is sent back to the browser. So we need a server to run the code.

Before you start working with PHP you need to install XAMPP or WAMP which can be used for the execution of these program. See how to setup these servers :

How to setup Xampp Server
How to setup Waampp Server

The output of the above code:

Points to be Noted:

  1. PHP statements are always to be ended by semicolon ;.

  2. A comment in PHP code is a line that is not read/executed as part of the program,is to be read by someone who is editing the code!

    // This is a single line comment
    # This is also a single line comment
    This is a multiple lines comment block
    that spans over more than
    one line
  3. In PHP, all user-defined functions, classes, and keywords (e.g. if, else, while, echo, etc.) are case-insensitive. However; in PHP, all variables are case-sensitive.

  4. PHP has no command for declaring a variable. A variable is created the moment you first assign a value to it:
    $txt="Hello world!";

  5. PHP is a Loosely Type Language In the example above, we can see that we did not have to tell PHP which data type the variable is. PHP automatically converts the variable to the correct data type, depending on its value.

Ok Friends now you are ready with sufficient environment required to work with PHP now please go back and follw the further articles to Complete PHP .