php (Hypertext Preprocessor)

Preview:

DESCRIPTION

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

Citation preview

Prepared by:

Chandan DasB.Tech 5th SemesterDept of CSECIT , KOKRAJHAR

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)

PHP stands for??

Personal Home Page

• 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

SCRIPTING LANGUAGE

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

SCRIPTING LANGUAGE

HOW PHP WORKS??

<?php

?>

BASIC PHP SYNTAX

• 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

• 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”

• 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

Syntax

if (condition)

code to be executed if condition is true;

else

code to be executed if condition is false;

THE IF...ELSE STATEMENT

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

• Strlen();

• Strcmp();

• Date();

• Time();

• Include();

• Require();

PHP FUNCTION

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

• Cookies

• Session

STATE MANAGEMENT

• 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

Syntax:

<?php start_session(); ?>

<?php start_session();

$_SESSION[‘user_name’]=‘’

$_SESSION[‘pwd’]=‘’

?> //create a session

select username,password

From table

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

<?php start_session();

$_SESSION[‘user_name’]=

$_SESSION[‘pwd’]=

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

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

?> //retrieve a session

• session_destroy();

• unset();

<?php start_session();

$_SESSION[‘user_name’]=

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

unset($_SESSION[‘user_name’]);

?> Name of the Logout button

– 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

• Wikipedia

• Google images

• www.w3schools.com

REFERENCES

THANK YOU

Recommended