What is PHP?
Php stands for pre hypertext programming language or hypertext preprocessor. It is a server site programming language like other programming language like Asp.net etc.
Now a day it is very much popular in website development. Many big websites like yahoo, Facebook and many other social networking sites are generally made in php .
Php files have a file extension .php, .php3 , .phtml etc.
Features of PHP
There are many features of php:
- It is server site programming language.
- Php is an open source language and it can be free download and use .
- It is a loosely type language there is no need to declare the type of variable in php.
Database in PHP
Php support many databases like MySQL, Informix, Oracel, ODBC etc. Rather than it is also having its database i.e. phpMyAdmin.
Basic Body Architecture of PHP
Statement;
Statement;
?>
The whole programmed in php is written in between .
Evolution of PHP
Php was developed by Ramus Lerdrof in 1994. After that it was modified by Zeev Suraski and Andi Gutmans in 1997.
After installation php in your computer you can test your browser by typing:
http://localhost and then press enter
Variables in PHP
Variables are used to store information or a value to its. Like other programming language php have its own variable .but in php there is no need to define its data type it will be automatically regret its vale that it is of integer or character type.
In php variable define with a sigh of ‘$’ i.e.
$a, $abc etc.
The first character after $ must be character or underscore. The remaining character in name may be letter , number or underscore.
Syntax :
$variable_name = value;
Example:
$a
$a=10;
$b=20;
$c= $a+$b;
First programme in PHP
Echo “Hello”;
php?>
echo: eco is used for output a string and must be ended with a semicolon. The string must be written in between doubleqoutes.
We can also use print as in place of echo.
Example:
Print “Hello My Name is Pankaj Singh”;
?>
Output: Hello My Name is Pankaj Singh
Example:
$abc=” Hello My Name is Pankaj Singh”;
Echo $abc;
Print $abc;
?>
Output of above program is:
Hello My Name is Pankaj Singh Hello My Name is Pankaj Singh
Comment in PHP
There are generally two types of comments used in php
- Single line comments : //
- Multiline comment: /*….*/
Example:
// this is a single line comment
?>
/* This
Is a
Multiline comment
*/
?>