Monday, September 21, 2009

PHP Introduction

PHP Stands For Pre Processor of Hypertext (Or) Hypertext pre Processor

PHP Definition : It is embedded server side scripting language.

Features of PHP

1. Open Source
2. Natural way of Accessing Data Base (No need of any Drivers)
3. Syntax and semantic is simple
4. Loosely Typed
5. Ability to Connect Multiple Databases
6. Full support in the form of built in functions
(No need to include any Header files to use any built in Functions in PHP)

To install PHP we have some third party tools

EX :

1. XAMPP
2. WAMP
3. Easy PHP

Note :

Our s/w is XAMPP , it includes Apache , My SQL , PHP , Perl for XP

Every server has some root Directory ( where we have to save the programs )

XAMPP - htdocs

WAMP - www

Easy PHP - www
-------------------------------------------------------------

All web servers are deped on Port 80

We can change the port no in :

XAMPP\apache\conf\httpd.conf

-------------------------------------------------------------

Create your folder in

C:\xampp\htdocs to save your programs ( ex : sampath)

-------------------------------------------------------------
Ex 1 :



Save the file in your folder sampath ( a.php )

Run the program :

Go to browser

http://localhost/sampath

select your program from the list to run it

Note :

1) if you save your PHP program with the name index.php in your folder sampath
the the program will automatically run when you are enter http://localhost/sampath in the browser

2) instead of giving localhost we can give like this also http://127.0.0.1/sampath

-------------------------------------------------------------

Variable


Variable is a memory location where we can store the values.

Ex 1 :
Var $a;
$a = ‘srihitha’; - Wrong

Ex 2 :
Var $a = ‘srihitha’; - Wrong

Ex 3 :
$a = ‘srihitha’; - correct

Conditions for variable names :

1. First char of var name must be in A-Z (or) a-z (or) _ (underscore) .
2. Spaces are not allowed.
3. Avoid built in functions and reserve words as variable names.

Data Types :

Numaric ( int – 4 bytes , float – 8 bytes )

String ‘abc’ or “abc”

Boolean True or False

Note :

If any char create problem in a string then use \

Ex :
“Hai \” I am sampath “

\ indicates to browser that coming char is not a special char.

Ex 1 :



Ex 2 :



Note : with using string conversion method it will convert string into integer when u Preformed arithmetic operation

Ex 3 :



Ex 4:



Boolean

Boolean a = true;
Boolean a = false;

Note : don’t put any quotations ( Ex : ‘treue’ )

Ex :



----------------------------------------------------------------

To get the data type of var

Ex 1 :



It will display data type and value.

Ex 2 :



It will display data type,length and value.

Ex 3 :


It will display data type and value.

Note :

“ “ are used for variable expansion

Ex :



-------------------------------------------------------------

Concatenation symbol is . or ,

For next line we can use ‘


-------------------------------------------------------------

Ex :

No comments:

Post a Comment