Sign In | Subscribe

Enter your Sign on user name and password.

Forgot password?
  • Follow us on:
Start learning today, and be successful in your academic & professional career. Start Today!
Loading video...
This is a quick preview of the lesson. For full access, please Log In or Sign up.
For more information, please see full course syllabus of Introduction to PHP
  • Discussion

  • Study Guides

  • Download Lecture Slides

  • Table of Contents

  • Transcription

  • Related Services

Lecture Comments (6)

0 answers

Post by DAUDA BIDEMI on August 23, 2014

pls how can i download this lectures to my laptop for my personal use

0 answers

Post by Florinel Cristian Marius-Pop on July 30, 2012


0 answers

Post by Ryan McCanna on February 8, 2012

has anyone read any headfirst books?

0 answers

Post by Arthur Aquino on December 11, 2011

@ jacob
Hypertext Transfer Protocol Secure (HTTPS) is a combination of Hypertext Transfer Protocol (HTTP) with SSL/TLS protocol. It provides encrypted communication and secure identification of a network web server.Hope i answered your question correctly..

1 answer

Last reply by: Govind Balaji Srinivasa Raghavan
Wed Jun 4, 2014 7:59 AM

Post by Jacob/Benja Share on November 26, 2011

what is https?

How PHP & The Web Work

  • A client is a resource or service requester that makes a request to a server to obtain a resource or have a service performed.
  • A server is a resource or service provider that either provides a requested resource to a client or performs a requested service for the client.
  • HTTP , or the Hypertext Transfer Protocol, is the set of communication rules that defines how web browsers and webservers interact on the Internet.
  • Uniform Resource Locators, or URLs , are used on the Internet to specify the location of a desired resource along with the means of retrieving it.
  • PHP is a server-side scripting language that gives a webserver the ability to run executable code each time a web client requests a particular resource.
  • PHP executable code can be intermingled with HTML markup.

How PHP & The Web Work

Lecture Slides are screen-captured images of important points in the lecture. Students can download and print out these lecture slide images to do practice problems as well as take notes while watching the lecture.

  • Intro 0:00
  • Lesson Overview 0:10
    • Lesson Overview
  • Client-Server Model 0:53
    • Client-Server Model
  • HTTP Protocol 2:15
    • Definition of Protocol
    • Hypertext Transfer Protocol (HTTP)
  • Uniform Resource Locators 3:46
    • Uniform Resource Locators (URLs)
    • Form of URLs
    • Accessing Webpages with URLs
  • Serving Webpages 6:14
    • Serving Webpages, Client Machine, and Server Machine
  • Static vs. Dynamic Webpages 8:30
    • Static Webpage
    • Dynamic Webpage
  • Server-Side Scripting 9:54
    • Server-Side Scripting
  • Static and Dynamic Webpage Coding Example 11:17
    • Static and Dynamic Webpage Coding Example
  • Serving Dynamic Webpages 13:07
    • Serving Dynamic Webpages

Transcription: How PHP & The Web Work

Hello again, and welcome back to's Introduction to PHP course.0000

In today's lesson, we are going to be going over some Web fundamentals and be discussing how PHP and the Web work.0005

We are going to start by talking about what is known as the client-server model, which is a model for distributed computing on the Internet.0013

We are going to talk about the http protocol, which is used when browsing Web pages.0019

We are going to talk about something you may be a little familiar with already, which is URL's, or Uniform Resource Locators.0025

And we are going to discuss how these different things work together to serve web pages from the Web server to a client.0032

Additionally, we are going to talk about the differences between static and dynamic web pages,0038

go over what server-side scripting is, and then talk about how server-side scripting is used to serve dynamic web pages.0043

First, the client-server model is basically a distributed computing model that describes how information is exchanged on the Web, or over a network.0055

It describes communication between two different parties--one known as a client and one known as a server.0064

Basically, a client is what is known as a resource or service requester.0070

A client makes a request to a server to obtain a resource or to have a particular service performed.0074

On the other side of things, a server is a resource or service provider0080

that either provides a requested resource to a client or performs a service requested by the client.0086

One thing to note is that the terms "client" and "server" both can kind of have several meanings.0094

"Client" can be used to refer both to an actual person using a Web client, browsing to a website,0098

and it can refer to client software, such as a Web browser.0106

And it can actually be used to refer to a client computer (which is maybe a computer where a Web browser is running).0109

On the other hand, "server" can be used to refer to the actual machine where a Web server is running,0115

or it can be used to refer to the software that is running, such as the Apache Web server.0122

The way you distinguish between what is meant by "client" or "server" is typically denoted by the context it's used in.0128

We know that the Web uses a client-server model for accessing web pages.0137

The way it does so is: it uses a set of rules or protocols.0144

In computing, protocols are basically a set of rules that denote how computers communicate with each other over a network.0148

There are a number of different protocols out there.0158

The one that is used on the Web, to browse to a web page0160

(which you may have heard of, and you might recognize from URL's that you have entered into the address bar of your browser),0163

is http--or it's formally known as the Hypertext Transfer Protocol.0169

What that protocol is: it defines how Web servers and Web browsers interact to be able to serve and view web pages.0175

Whenever you type an address in your Web browser (such as this), you will notice that there is the http 4-letter mnemonic at the beginning of the link.0184

What that is basically doing, is specifying to your Web browser that you want to request a particular web page,0195

and you want to use the http protocol to do it.0203

It is standard protocol used on the Web to access web pages.0206

So, you don't actually even...when you type an address into your Web browser, you could just type in

You will actually see that your browser goes ahead and inserts this http part here at the beginning,0217

because that is the method used to access websites.0222

How does one decide to tell the Web browser what resource it wants to view, what web page it wants to view, and how to view it?0229

The way it does that is through a URL, which is this right here, which we had seen on the previous page.0238

Basically, a URL describes the location of a particular resource on the Internet that you want to view--for example, a web page.0243

And then, it also describes the method of retrieving it.0251

URL's have a specific form: this is a simplified form--there are additional parts that can be added to it.0254

Basically, it contains a scheme which describes the means of retrieving a particular resource.0261

It contains a host name, which is basically the name, or the IP address, of the server that has the content you are trying to retrieve.0267

It can optionally have--well, it actually always has in the background--a port specified,0276

which says on what port you want to connect to the particular server.0281

That "port" is a networking term that is used, that describes how...0286

Basically, computers communicate with each other, and they do so using ports,0291

which are basically numbered assets on the computer (for example, Port 80, Port 100).0294

The last part of the URL is the path; and basically, what that is, is the path to the resource you are trying to find0302

on the server that you are communicating with.0310

If we are accessing web pages, URL's typically have the form shown here.0315

For the scheme, it has, as we saw on the last slide, the http specified.0319

That specifies that you should use the http protocol to load a particular resource on the Web.0324

In this case, the resource is a file called index.html.0333

And then, index.html is located in php directory on the server

The way that you connect to that server at is using port 80.0346

Now, port 80 is the default used for communicating with Web servers, and it is typically left out of URL's.0352

And actually, pretty much any time you browse anything on the Web, you never see it.0357

But behind the scenes, it is implicitly being used.0361

That is how your Web browser communicates with the Web server to be able to use http to download a web page to your browser.0363

How does all this work together with the client-server model, the http protocol, and using URL's?0376

Well, let's say, for example, we have this URL here that specifies that we want to use the http protocol0382

to, again, load or view the file index.html located in the php directory of the server.0388

And again, implicitly, it is going to use port 80 to connect.0399

How does that happen?0402

Well, the first thing you do is: when you type this address into your Web browser, your Web browser initiates what is known as an http request.0403

What it does is: it sends that request over the Internet to the server.0418

The server has what is known as an http server--or, more commonly, a Web server--that is listening on port 80 for any http requests.0425

And actually, the most common Web server that is used (or http server) is the Apache Web server.0436

And that is actually what we are going to be using in this course.0442

When you send out, from your Web browser, an http request to,0444

the (for example) Apache Web server will receive that request, and it will dissect the URL and discover that0449

you want to receive the index.html file loaded in the php directory.0457

Well, the Apache Web server knows how to map these URL's to specific places on a hard drive.0463

So, it goes to the hard drive and loads the index.html file.0468

The file is loaded up by the http server, and then it sends the file back to the requesting client, or requesting Web browser,0473

using what is known as an http response.0482

This, basically, is the cycle that happens every time you browse to a web page.0490

An http request is issued to a remote server (typically), and then the server responds0496

by looking up the requested resource on a hard drive and then sending it back by an http method and an http response.0502

The example that we just went over is typically what is used for serving what is known as a static web page.0512

A static web page is one whose content is basically not altered, nor is any task performed, when a web client requests the page.0517

So, basically, a web client doesn't perform any actions or provide any input to the page; it is just asked for and returned.0526

A dynamic web page, on the other hand, can respond and does respond to a web client's action or input.0536

For example, a web client or a web user might submit HTML form information,0544

like we saw in the introductory lecture about our web store application, where our users submit their shipping information.0551

A dynamic web page can take that input and then perform some action or generate HTML content based on that.0560

For example, in the case of our web store application, it could generate an output that says,0567

"This is the address you provided where we are going to ship things to."0575

Or, it can even perform tasks, like accessing a database or even processing a credit card transaction.0578

PHP is a server-side scripting language that is used for the creation of these dynamic web pages and web applications.0586

We have mentioned a little bit, in the introductory lecture and now, about server-side scripting.0595

Basically, what server-side scripting is, is what PHP is: it's a programming language that is executed on the server whenever a user requests a resource.0600

For example, when a web client requests a PHP page from the web server (for example, at,0611

when that page is requested, basically, executable code is run that can be used to perform some actions0619

or to generate some dynamic HTML content that gets sent back to the user.0626

Typically, for a server-side scripting language, the code is always executed on the server.0632

And then it is output, typically, in the form of an HTML; it is returned seamlessly to the web client.0637

From the web client's point of view, all they see is them sending a request for a particular PHP page to a web server.0642

And then, they receive HTML output in response.0649

It is basically the ability to execute code on each page request0654

that allows PHP to take your web pages and web applications from the static to the dynamic.0659

Additionally, most server-side scripting languages, including PHP, allow executable code (or the server-side scripting code)0667

to be intermingled with HTML markup.0674

For example, if you look at a static HTML page, it just contains regular HTML content.0679

And if we look at the source, we can see, it just contains some simple HTML tags.0690

And that it is all it contains--HTML code; and that is a static web page.0696

However, if we look at a page called dynamic.php, for example, and we load that up, this is an example of a dynamic web page0700

that executes server-side scripting code when it is being processed, or when it is requested.0709

In this example, this web page actually just prints out the current day and time, which is obviously going to change every time the page is requested.0716

If we refresh the page, you can see that the time has actually changed.0723

Now, if we actually go and look at the source code for this particular page,0728

we can see that, rather than just having HTML tags, there actually is a section here0738

(and we are going to learn more about this as the course goes on) where you actually have PHP code.0744

This is how you designate PHP code; and you have it intermingled with HTML.0749

Everything up here is just standard HTML, as we know about.0755

And then, this section of code right here, which is the PHP code, is what actually...0759

Basically, what it does in this case is just echo or output the current date.0763

Every time we view this page--we request this page from our web browser--this page is basically interpreted by PHP.0768

Any HTML is passed back to you, and then any PHP code is run, and the output generated by that is passed back to the user, as well.0777

Let's sort of take a look at the same diagram we had before, but now we're going to use it to talk about serving dynamic web pages.0789

For example, let's say we have a new URL that is requesting a PHP page.0796

It is requesting index.php, and the PHP directory is

What is going to happen is similar to before.0807

The web client, or the web browser, is going to issue an http request to the web server located at

That request is just going to say, "I want the contents of the index.php file."0821

Well, when Apache receives that, it knows (it is configured to know) that PHP files are not just simply to be returned to the user.0828

For example, Apache wouldn't want to return this file as is to the user.0836

This content right here, this PHP code, is sort of meaningless to the user.0841

What the user wants is that code executed, and its output.0847

So instead, what happens is: when Apache receives a request for a PHP file,0851

it basically invokes what is known as the PHP Interpreter (and you will hear me refer to that as the PHP Interpreter, the PHP Parser, just PHP in general).0856

What the PHP Interpreter does is: it loads the PHP file from the hard drive,0865

goes through, and directly passes on any HTML it finds in the page,0870

but then also goes ahead and executes any PHP code and then passes on any output generated by that HTML code to the client.0875

PHP...after loading the file from the hard drive, it executes any PHP code.0883

It generates an HTML output file, which it passes back to Apache.0887

And then Apache, through the same method as before, sends it back by an http response.0892

So again, from the client's point of view, basically, the same scenario is happening.0901

It is simply requesting a file, and the web server is returning an HTML file.0905

However, the difference is: on the server side, there is an extra step in here, which is where PHP comes in.0912

It's a server-side scripting language, and what it does is: it executes code that can be used to dynamically generate HTML, for example.0918

That ends today's lesson; thank you for watching look forward to seeing you next time.0927