36
Prepared by: Chandan Das B.Tech 5 th Semester Dept of CSE CIT , KOKRAJHAR

php (Hypertext Preprocessor)

Embed Size (px)

DESCRIPTION

A brief description about php and how it works on web server.

Citation preview

Page 1: php (Hypertext Preprocessor)

Prepared by:

Chandan DasB.Tech 5th SemesterDept of CSECIT , KOKRAJHAR

Page 2: php (Hypertext Preprocessor)

INTRODUCTION• It is an interpreted, server-side scripting language.

• Originally designed for web development.

• Similar languages are Perl, ASP.NET, Ruby, JSP (Java Server Pages)

• Embedded into HTML

• Can use DB (MySQL, Oracle, Microsoft SQL, PostgreSQL)

Page 3: php (Hypertext Preprocessor)

PHP stands for??

Personal Home Page

Page 4: php (Hypertext Preprocessor)
Page 5: php (Hypertext Preprocessor)

• Began in 1994 by Rasmus Lerdorf

• Soon he named PHP/FI to build simple, dynamic web applications.

• In 1995 -the release of PHP/FI as "Personal Home Page Tools (PHP Tools) version 1.0".

• In 1997 Zeev Suraski and Andi Gutmans rewrote the parser and formed the base of PHP 3, changing the name PHP: Hypertext Preprocessor.

• On May,2000, PHP 4 was released,

• On July , 2004, PHP 5 was released, powered by the new Zend Engine II.

• In 2008 PHP 5 became the only stable version under development.

• Finally after a vote the current version released in 2014 .

HISTORY

Page 6: php (Hypertext Preprocessor)

SCRIPTING LANGUAGE

Page 7: php (Hypertext Preprocessor)

• A scripting language is:– cross-platform since interpreter is easy to port– implicit variable declaration – compiled on demand– Extending – Glue programming

SCRIPTING LANGUAGE

Page 8: php (Hypertext Preprocessor)

HOW PHP WORKS??

Page 9: php (Hypertext Preprocessor)
Page 10: php (Hypertext Preprocessor)
Page 11: php (Hypertext Preprocessor)
Page 12: php (Hypertext Preprocessor)
Page 13: php (Hypertext Preprocessor)
Page 14: php (Hypertext Preprocessor)
Page 15: php (Hypertext Preprocessor)
Page 16: php (Hypertext Preprocessor)
Page 17: php (Hypertext Preprocessor)

<?php

?>

BASIC PHP SYNTAX

Page 18: php (Hypertext Preprocessor)

• All variables in PHP start with a $ sign symbol.

• Variables may contain strings, numbers, or arrays.

<html>

<body>

<?php $txt="Hello World"; echo $txt;

?>

</body>

</html>

VARIABLES IN PHP

Page 19: php (Hypertext Preprocessor)

• String– 'My name is x.'– "My name is $name."

• Boolean• Integer• Floating point• Array

– $a=array("tokyo", "hanoi", "london")– $a=array("japan" => "tokyo", "vietnam" =>

"hanoi", "england" => "london")– $a[2]– $a["vietnam"]

DATA TYPES$name=“x”

Page 20: php (Hypertext Preprocessor)

• String literals (constants) enclosed in double quotes “ ” or single quotes ‘ ’

• Within “”, variables are replaced by their value: – called variable interpolation. “My name is $name, I think”

• Strings are concatenated (joined end to end) with the dot operator “key”.”board” == “keyboard”

STRING HANDLING

Page 21: php (Hypertext Preprocessor)

Syntax

if (condition)

code to be executed if condition is true;

else

code to be executed if condition is false;

THE IF...ELSE STATEMENT

Page 22: php (Hypertext Preprocessor)

Syntax

switch (expression)

{

case label1: code to be executed if expression = label1; break;

case label2: code to be executed if expression = label2; break;

default: code to be executed if expression is different from both label1 and label2;

}

THE SWITCH STATEMENT

Page 23: php (Hypertext Preprocessor)

• Strlen();

• Strcmp();

• Date();

• Time();

• Include();

• Require();

PHP FUNCTION

Page 24: php (Hypertext Preprocessor)

• It is used to help web applications to maintain their state across several HTTP requests when needed.

• Cookies

• Session

STATE MANAGEMENT

Page 25: php (Hypertext Preprocessor)

• Better option of cookie

• Store information about a user. They are available only for a particular application and hold information of only one single user.

SESSION

Page 26: php (Hypertext Preprocessor)

Syntax:

<?php start_session(); ?>

Page 27: php (Hypertext Preprocessor)

<?php start_session();

$_SESSION[‘user_name’]=‘’

$_SESSION[‘pwd’]=‘’

?> //create a session

Page 28: php (Hypertext Preprocessor)
Page 29: php (Hypertext Preprocessor)

select username,password

From table

Where username=‘textbox1’ and password=‘textbox2’

Page 30: php (Hypertext Preprocessor)
Page 31: php (Hypertext Preprocessor)

<?php start_session();

$_SESSION[‘user_name’]=

$_SESSION[‘pwd’]=

if(isset($_SESSION[‘username’]))

Echo “Welcome”. $_SESSION[‘name’]

?> //retrieve a session

Page 32: php (Hypertext Preprocessor)

• session_destroy();

• unset();

<?php start_session();

$_SESSION[‘user_name’]=

if(isset($_POST[“lgt_btn"]))

unset($_SESSION[‘user_name’]);

?> Name of the Logout button

Page 33: php (Hypertext Preprocessor)
Page 34: php (Hypertext Preprocessor)

– Support for MySQL, Oracle, dbm, DB2, PostgreSQL

– Can connect to any database which provides an ODBC driver (Open Database Connectivity Standard) – e.g. MS Access.

– Supported on Windows, Mac OS X, other Unix-like systems (e.g. Linux).

– Similar syntax and features as C++ and Java.

– PHP designer,Wampp/Xampp are free of cost.

FEATURES OF PHP

Page 35: php (Hypertext Preprocessor)

• Wikipedia

• Google images

• www.w3schools.com

REFERENCES

Page 36: php (Hypertext Preprocessor)

THANK YOU