+ All Categories
Home > Documents > Introduction to HTML & PHP - proness.kix.in · Hypertext Preprocessor PHP: Hypertext Preprocessor...

Introduction to HTML & PHP - proness.kix.in · Hypertext Preprocessor PHP: Hypertext Preprocessor...

Date post: 26-Jun-2020
Category:
Upload: others
View: 30 times
Download: 0 times
Share this document with a friend
23
Introduction to HTML & PHP Anant Narayanan 17 August 2007
Transcript
Page 1: Introduction to HTML & PHP - proness.kix.in · Hypertext Preprocessor PHP: Hypertext Preprocessor As the name suggests you do some processing and output HTML Sometimes also called

Introduction toHTML & PHP

Anant Narayanan17 August 2007

Page 2: Introduction to HTML & PHP - proness.kix.in · Hypertext Preprocessor PHP: Hypertext Preprocessor As the name suggests you do some processing and output HTML Sometimes also called

Overview of the WWW

Client Server Architecture

Any network always works in layers

We work on the topmost “Application” layer

The protocol used is HTTP. Another lower layer is at work: TCP/IP

Page 3: Introduction to HTML & PHP - proness.kix.in · Hypertext Preprocessor PHP: Hypertext Preprocessor As the name suggests you do some processing and output HTML Sometimes also called

Dissecting the URL

http://www.mnit.ac.in/

Protocol

Subdomain Domain

Top Level Domain

Page 4: Introduction to HTML & PHP - proness.kix.in · Hypertext Preprocessor PHP: Hypertext Preprocessor As the name suggests you do some processing and output HTML Sometimes also called

IP Addresses

Every computer on a network is required to have an “address”

Version 4 is the most popular and is of the form: a.b.c.d

Combination of 4 numbers, each in the range 0-255

Page 5: Introduction to HTML & PHP - proness.kix.in · Hypertext Preprocessor PHP: Hypertext Preprocessor As the name suggests you do some processing and output HTML Sometimes also called

Distributing Addresses

The scheme leaves us with a combination of 4,29,49,67,296 addresses

There are certainly more computers than that!

Not to mention, certain addresses are considered invalid

Page 6: Introduction to HTML & PHP - proness.kix.in · Hypertext Preprocessor PHP: Hypertext Preprocessor As the name suggests you do some processing and output HTML Sometimes also called

The DNS

Domain Name System

Converts domain names to IP Addresses

Works hierarchically

Page 7: Introduction to HTML & PHP - proness.kix.in · Hypertext Preprocessor PHP: Hypertext Preprocessor As the name suggests you do some processing and output HTML Sometimes also called

The path of a web page

User requests http://www.mnit.ac.in/

Browser asks OS to “resolve”

Browser connects to IP address

Sends an HTTP “Request”

Web Server responds with an HTTP “Response”

Page 8: Introduction to HTML & PHP - proness.kix.in · Hypertext Preprocessor PHP: Hypertext Preprocessor As the name suggests you do some processing and output HTML Sometimes also called

HTML

Hypertext Markup Language

Used to deliver content over HTTP

Based on the superset XML

The language used to design web pages

Page 9: Introduction to HTML & PHP - proness.kix.in · Hypertext Preprocessor PHP: Hypertext Preprocessor As the name suggests you do some processing and output HTML Sometimes also called

Example

<html> <head> <title>My First Web Page</title> </head> <body> <h1>Hello World!</h1> </body></html>

Page 10: Introduction to HTML & PHP - proness.kix.in · Hypertext Preprocessor PHP: Hypertext Preprocessor As the name suggests you do some processing and output HTML Sometimes also called

Tags & AttributesEverything enclosed in <> is known as a tag

Every tag can have a set of associated attributes

Learn the tags yourself!

<a>, <p>, <br>, <form>, <input>, <table>,<div>, <textarea>, <span>, <h1>, <h2> etc...

Page 11: Introduction to HTML & PHP - proness.kix.in · Hypertext Preprocessor PHP: Hypertext Preprocessor As the name suggests you do some processing and output HTML Sometimes also called

What’s wrong with HTML

It’s static!

Once you create an HTML page, it stays like that forever

Although you can create forms in HTML, how do you actually process them?

Page 12: Introduction to HTML & PHP - proness.kix.in · Hypertext Preprocessor PHP: Hypertext Preprocessor As the name suggests you do some processing and output HTML Sometimes also called

Server side scripting

Browsers understand only HTML

Solution: Do the processing on the web server, but return HTML pages

Different HTML pages are generated for different users

Page 13: Introduction to HTML & PHP - proness.kix.in · Hypertext Preprocessor PHP: Hypertext Preprocessor As the name suggests you do some processing and output HTML Sometimes also called

Hypertext PreprocessorPHP: Hypertext Preprocessor

As the name suggests you do some processing and output HTML

Sometimes also called a scripting language

You can “submit” HTML forms to PHP scripts

Page 14: Introduction to HTML & PHP - proness.kix.in · Hypertext Preprocessor PHP: Hypertext Preprocessor As the name suggests you do some processing and output HTML Sometimes also called

A Sample Form<html><head><title>Form</title></head><body> <form name=“test” action=“submit.php” method=“post”> Please Enter your name: <input type=“text” name=“uname”/> </form></body></html>

Page 15: Introduction to HTML & PHP - proness.kix.in · Hypertext Preprocessor PHP: Hypertext Preprocessor As the name suggests you do some processing and output HTML Sometimes also called

submit.php<?phpif (isset $_POST[‘uname’]) { $message = “Hello ”. $_POST[‘uname’].“!”;} else { $message = “Hello Unnamed!”;}?><html> <head><title>Hello!</title></head> <body> <h1><?php echo $message;?></h1> </body></html>

Page 16: Introduction to HTML & PHP - proness.kix.in · Hypertext Preprocessor PHP: Hypertext Preprocessor As the name suggests you do some processing and output HTML Sometimes also called

PHP for Programming

boolean, integer, float, string

array, object

resource, NULL

Page 17: Introduction to HTML & PHP - proness.kix.in · Hypertext Preprocessor PHP: Hypertext Preprocessor As the name suggests you do some processing and output HTML Sometimes also called

Booleans

TRUE

FALSE

(Case-Insensitive)

0, 0.0, “”, “0”, array(), NULL are all FALSE

Everything else is TRUE (including -1)

Page 18: Introduction to HTML & PHP - proness.kix.in · Hypertext Preprocessor PHP: Hypertext Preprocessor As the name suggests you do some processing and output HTML Sometimes also called

Integers

Very Similar to C

$a = 1234; $b = -123; $c = 0123; $d = 0x1A

Any overflow will automatically become a float

$x = 2147483647; // (int)$y = 2147483648; // (float)

Page 19: Introduction to HTML & PHP - proness.kix.in · Hypertext Preprocessor PHP: Hypertext Preprocessor As the name suggests you do some processing and output HTML Sometimes also called

Strings

Single Quote, Double Quote, Heredoc

You can include variables and escape sequences in double quoted strings

$x = “Hello!”; echo “$x”; echo ‘$x’

Page 20: Introduction to HTML & PHP - proness.kix.in · Hypertext Preprocessor PHP: Hypertext Preprocessor As the name suggests you do some processing and output HTML Sometimes also called

Arrays

array( [key =>] value, ...)

key may be an integer or string, value can be anything (including an array)

$arr1 = (“Hello”, “World”); echo $arr1[0];

$arr2 = array(“name” => “PHP”);echo $arr2[‘name’];

Page 21: Introduction to HTML & PHP - proness.kix.in · Hypertext Preprocessor PHP: Hypertext Preprocessor As the name suggests you do some processing and output HTML Sometimes also called

Objects

Classes, Properties, Methods

Page 22: Introduction to HTML & PHP - proness.kix.in · Hypertext Preprocessor PHP: Hypertext Preprocessor As the name suggests you do some processing and output HTML Sometimes also called

Objects

Classes, Properties, Methods

Oh wait, you’re getting bored!Let’s leave this for another day

Questions?

Page 23: Introduction to HTML & PHP - proness.kix.in · Hypertext Preprocessor PHP: Hypertext Preprocessor As the name suggests you do some processing and output HTML Sometimes also called

Thank You!

http://foss.mnit.ac.in/


Recommended