Home > Backend Development > PHP Tutorial > How web programs work

How web programs work

WBOY
Release: 2016-08-08 09:32:06
Original
929 people have browsed it

1.WebHow the program works

(1) The meaning of the word Web

Network:【Computer】Computer network, network

Web: [Computer] World Wide Web (World Wide Web), Internet (Internet)

Webprogram, as the name suggests, is a program that works on Web.

(2) Working principle of stand-alone program

A stand-alone computer, that is, a computer that is not connected to other computers and is not in a network. For example: two single machines A, B, only the program X is installed on A, if you want to get the running results of X on B , you must install X on B and then run it. If there are many B computers, you need to install and run them one by one. They cannot communicate and collaborate directly with each other. As shown in Figure 1.

(3) Client/Working principle of server program

Connect single machines into a network, such as connecting A and B into a network, then they can provide services between them, such as A providing services to B. Common services are file sharing, FTPfile downloading, etc. We call the computer that provides (responds to) services a server (Server), and the computer that accepts (requests) services is called a client (Client), also called a workstation (Workstations). The working principle of the client /server program is shown in Figure 2.

The roles of server and client can be switched. A computer can provide services to itself. At this time, it is both a server and a client. For example, if the computer A shares its own folder a, and then finds A on the Internet, you can download a, means that you have provided services to yourself, requested and Service responded.

This method of inter-computer collaboration between

client/server is called C/Smethod, or C/Sarchitecture.

C/SThe program is divided into two parts: server side and client side, which are called server-side program (or service program) and client program (or client program) respectively. For client programs, each client must be installed separately. This is the same as the distribution of stand-alone programs, and it is also very troublesome. However, after the client program is installed, you can interact with the server through the communication line, or communicate with other clients through the server. A typical example is the commonly used chat program QQ, as shown in Figure 3.

(4) Browser/How the server program works

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

At this time, the client program is the browser, and the installation of the browser is completed with the installation of the operating system, and does not require additional installation by the user. For them, when using B/S programs (such as reading news online, sending and receiving emails), they do not need to install special client programs and can operate directly in the browser. This makes the maintenance of the B/S program very convenient, because you don’t have to worry about the client program, you only need to maintain the server program.

(5)C/S, B/SComposition of server

A server is a machine responsible for service tasks. These service tasks are generally completed by specialized software. Generally speaking, server software with certain service functions and the machine on which it is located are collectively referred to as XXservers (XX represents a specific service). These software can be concentrated in one machine (as shown in the figure 5), such a machine can be called a centralized server; or they can exist alone in a certain machine (as shown in the figure 6), like this A machine can be called a stand-alone server, and multiple stand-alone servers can form a server farm or matrix.

According to service tasks, several common server software are shown in Table 1.

Server-side script: A program written in a server-side programming language.

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

(6)B/SThe specific process of program work (picture 7)

(7)PHP The specific process of program work

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

The user requests the PHP file from the server through the browser (such as entering in the address bar: http://localhost/index.php), Apache looks for the file requested by the browser in the user document release directory on the server PHP file, if it is not found, an error message will be returned to the browser, otherwise, it will be submitted to the PHP interpreter for interpretation and execution, and the PHPinterpreter will respond to PHP The file is grammatically analyzed. If a grammatical error is found, the error message (represented by a code that the browser can recognize) is returned to the browser via Apache, otherwise the PHP program (which may include database The operation of MySQL), will return the PHP program execution result (represented by a code that the browser can recognize) to the browser via Apache, and the browser will interpret and execute the returned result. , the execution results are displayed in the browser window.

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

2. Browser working process

(1)WebClient workProcess

Any application system must have an interface that provides user operations, that is, the user interface. The work of the browser, from the perspective of the entire B/S program, is an interface (interface) for users to interact with the B/S program. Its mission is:

A. Collect user-entered data

B. Send user data to server

C. Receive the response returned by the server

D. Interpret and execute these codes

It can be seen that the browser plays the role of an agent (Agent) of the server to the user. This agent has the role of collecting messages, requesting responses, and interpreting instructions sent back by the server.

(2)WebClient Code

Whether it is organizing the interface used to collect user data, or interpreting instructions from the server to form the resulting interface, it is all implemented using Web client code. Commonly used Web client codes include HTML language, JavaScript language, CSS, XML and other languages.

3.HTMLHow it works

(1)HTMLIntroduction

HTML: Hyper Text Markup Language , hypertext markup language.

At the end of the

20century80, Tim Berners-Lee worked at the European Particle Physics Laboratory (CERN: the European Laboratory for Particle Physics) WWW The father of ) discovered through research that people’s visual processing is based on pages. So he came to a conclusion: electronic data should be presented in pages. With this as a starting point, he used hypertext-centric management methods to organize information on the Internet, and proposed methods for accessing and browsing web pages: established a hypertext markup language; designed the Hypertext Transfer Protocol (HTTP : Hypertext Transport Protocol), used to obtain hyperlinked files; use Uniform Resource Locator (URL: Uniform Resource Locator) to locate network files, sites or servers.

(2)HTMLHow it works

HTML is not essentially a programming language, but a markup language. The so-called mark is also called a label in some books. From an object-oriented perspective, it means the identification of browser objects. It is used to control the performance of browser sub-objects such as text and images in the browser, as well as how to establish tags for links between files. These tags are placed in text format files. The biggest difference between programs is that they can be used to control the operating system or application program to execute and complete a certain job. Hypertext Markup Language documents should be as formal as possible to have the same effect regardless of whether they are opened in any browser on any operating system.

(3)Basic structure of HTML

A. Version statement, that is, prologue (Prologue)

B.Head(Head

C.Body (Body)

The above introduces the working principle of Web programs, including aspects of content. I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template