Detailed explanation of the working principle of Web programs

Source: Internet
Author: User
Tags ftp file
This article mainly introduces the knowledge about the working principle of Web programs, which is very comprehensive. For more information, see

This article mainly introduces the knowledge about the working principle of Web programs, which is very comprehensive. For more information, see

1. How Web programs work

(1) meaning of the word Web

Network: computer Network, Network

Web: [computer] World Wide Web (WorldWideWeb), Internet (Internet)

Web programs, as the name implies, are programs that work on the Web.

(2) working principle of a Single-Host Program

A single machine, that is, a computer that is not connected to another computer, is not in the network. For example, for two single machines A and B, only program X is installed on A. To obtain the running result of X on B, you must install X on B and then run it. If there are many type B computers, install and run them one by one. They cannot communicate and collaborate directly. 1.

(3) working principles of client/server programs

Connect A single machine to A network. If A and B are connected to A network, services can be provided between them. For example, A provides services to B. Common services include file sharing and FTP file download. We call the computers that provide (response) services a Server, the computers that receive (request) services a Client, or Workstations ). The working principle of the client/server program 2 is shown.

The roles of the server and client can be converted. A computer can provide services to itself. In this case, it is both a server and a client. For example, if computer A shares its folder a and finds A on the network, it can download a, that is, it provides services to itself, requests and responds to services.

The Client/Server is a collaborative mode between computers, called the C/S mode or the C/S architecture.

The C/S program is divided into two parts: the server side and the client side, respectively known as the server side program (or service program) and the client program (or customer program ). For client programs, each client also needs to be installed separately, which is the same as the distribution of standalone programs, which is also very troublesome. However, after the client program is installed, you can use the communication line to interact with the server or communicate with other clients through the server. A typical example is QQ, a common chat program, as shown in figure 3.

(4) How browser/server programs work

If you send a request to the server through the Browser in the client and receive the response result, then, we call this collaboration method B/S, or B/S architecture, its working principle 4 is shown below:

At this time, the client program is a browser, and the browser installation is completed with the installation of the operating system, no additional installation is required. For them, the use of B/S programs (such as surfing the internet to watch news, send and receive emails), do not need to install a dedicated client program, you can directly operate in the browser. This makes the maintenance of the B/S program very convenient, because you do not need to care about the client program, as long as you maintain the server program.

(5) Composition of C/S and B/S servers

A server is a machine responsible for service tasks. These service tasks are generally completed by specialized software. Generally, server software with certain service functions and their machines are collectively called XX servers (XX indicates a specific service ). These software can be concentrated on one machine (5). Such a machine can be called a centralized server, or it can be independently stored on one machine (6 ), such a machine can be called a stand-alone server. Multiple stand-alone servers can form a server group or matrix.

Common server software by service task is shown in table 1.

Server script: a program written in the programming language of the server.

Server programming language: a programming language that runs only on the server and is interpreted and executed by the server, such as PHP.

(6) specific procedures of B/S program work (7)

(7) specific process of PHP program work

The specific process is the collaboration process between Apache, PHP, and browsers:

The user requests the PHP file (for example, enter it in the address bar) from the server through the browser. Apache searches for the PHP file requested by the browser under the user document publishing directory on the server. If the PHP file cannot be found, an error message is returned to the browser. Otherwise, the error message is submitted to the PHP interpreter for explanation and execution. The PHP interpreter analyzes the syntax of the PHP file. If a syntax error is found, the error message is returned by Apache (indicated by code recognized by the browser) to the browser. Otherwise, the PHP Program (which may include operations on the MySQL database) is executed ), return the PHP program execution result (represented by code recognized by the browser) to the browser through Apache. the browser interprets and executes the returned result, and the execution result is displayed in the browser window.

If the file requested by the browser is not a PHP file, it is an HTML file or a JavaScript file. This process is simplified: Apache searches for the HTML file or JavaScript file requested by the browser in the user document release directory on the server. If the file cannot be found, an error message is returned to the browser. Otherwise, return it to the browser. The browser interprets and executes the returned results. The execution results are displayed in the browser window.

2. browser Working Process

(1) Web Client Working Process

Any application system must have an interface that provides user operations, that is, the user interface. From the perspective of the whole B/S program, browser work is an interface (Interface) for users to deal with B/S programs ). Its task is:

A. Collect User input data

B. Send user data to the server

C. Receive the response from the server

D. Explain and execute the code

It can be seen that the browser plays the role of a proxy (Agent) of the server in the user. This proxy is used to collect messages, request responses, and explain the instructions sent back by the server.

(2) Web client code

The Web client code is used to organize the interface for collecting user data, or to interpret the instructions from the server to form a result interface. Common Web Client codes include HTML, JavaScript, CSS, XML, and other languages.

3. How HTML works

(1) Introduction to HTML

HTML: HyperTextMarkupLanguage, hypertext markup language.

At the end of 1980s, TimBerners-Lee (father of WWW), working at CERN: theeuropeanlabloratoryforparticipant physics, found that people's visual processing is page-based. So he came to the conclusion that electronic materials should be presented on pages. Starting from this, He used Hypertext-centric management to organize information on the network, and proposed a method for accessing and browsing web pages: the establishment of hypertext markup language; A Hypertext Transfer Protocol (HTTP: HypertextTransportProtocol) is designed to obtain hyperlink files. A uniform resource locator (URL: UniformResourceLocator) is used to locate network files, sites, or servers.

(2) how HTML works

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.