PHP: A Server-Side Scripting Language - History, Syntax, and Data Handling, Slides of Computer Programming

An introduction to php, a popular server-side scripting language. It covers the history of php, its basic characteristics, syntax, and data handling using forms and get/post methods. Learn about the basics of php syntax, a first php program, server round trips using forms, and the differences between get and post.

Typology: Slides

2012/2013

Uploaded on 09/27/2013

vikrant
vikrant 🇮🇳

4.4

(9)

119 documents

1 / 24

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Introduction to PHP and
Server Side Technology
docsity.com
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18

Partial preview of the text

Download PHP: A Server-Side Scripting Language - History, Syntax, and Data Handling and more Slides Computer Programming in PDF only on Docsity!

Introduction to PHP and

Server Side Technology

PHP History

 Created in 1995  PHP 5.0 is the current version  It’s been around since 2004

The Basics of PHP Syntax

 PHP script always appears between  ****  PHP statements always end in a semi-colon  Comments have the same format as JavaScript  PHP IS CASE SENSITIVE

A First PHP Program

 As in  **

**

A First Server Round Trip

Using Forms (2)

 The following form posts to the page named Welcome.php ( action attribute)

** Name: Age:

**

A First Server Round Trip

Using Forms (3)

 Welcome.php contains the script to process the posted data **

Welcome ! You are years old.

**

GET and POST (Introduction)

 There are two basic ways to send data back to a Web server  We call these HTTP verbs  In all there are about 30 verbs  http://annevankesteren.nl/2007/10/http-methods  Both GET and POST send data to Web servers

HTTP GET

GET sends is data through the URL itself as a query string  The URL looks something like this  http://localhost/PhpProjectDemo1/welcome.php ?fname=zaphod&age=  **** values appear after the?

 Data appears as key=value pairs

 A & separates each key=value pair

 You don’t write the URL – HTTP does!

HTTP GET and POST

(Comparison)

 GET

 Query strings are small (100 characters)  Posted data is visible  It’s possible to bookmark the page  PUT  Large data blocks can be posted  Posted data is hidden  Page cannot be bookmarked

Reading Posted Data

$_GET and $_POST retrieve data send to the server via a GET or POST , respectively  They are built-in functions  Pass the ID of the input control as an argument

PHP Variables

 Like JavaScript, variables are ‘loosely typed’  Variables can be declared anywhere in a PHP script  Variable names  Must begin with a letter or underscore ‘_’ character  The following characters can be letters, numbers or the underscore  Variables cannot contain spaces

PHP Variables (Declaring)

 Variable declarations begin with the dollar sign ‘$’, followed by the variable name  An equals sign and value follow the declaration  Examples: $userName = “joe”; $pi = 3.14;

Using Numeric Variables (2)

 The following prints 10 + 100 because the value is quoted

$x = 10; $y = 100; print "$x + $y";

PHP Strings (Introduction)

 Strings work in PHP the same way they work in other languages  There are several string functions:  http://w3schools.com/php/php_ref_string.asp  The dot (.) is the concatenation operator