Home > Backend Development > PHP Tutorial > How web programs work, how web works_PHP tutorial

How web programs work, how web works_PHP tutorial

WBOY
Release: 2016-07-13 10:11:12
Original
934 people have browsed it

How the Web program works, how the web works

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)

Web program, 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 A > Install X on and then run it. If there are many computers in the B category, 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 stand-alone machines into a network, such as

A

and

B are connected into a network, then they can provide services between them, such asA provides services to

B. Common services are file sharing, FTPfile download, 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 workstations (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, the computer A shares its own folder

a

, and then finds A

, you can download

a,

, that is, you have provided services to yourself and requested and responded to services. Client/Server This type of collaboration between computers is called the C/S method, or C/S architecture.

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/Working principle of server program

If you make a request to the server through the browser

(Browser)

in the client and receive the response result, then, at this time, we call this collaboration method

B/S

method, or B/S architecture, its working principle is as shown in the figure

4

Shown: 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/S

Server composition

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 XX servers (XX represents a specific Serve). These software can be concentrated in a machine (as shown in the figure 5), and such a machine can be called a centralized server; it can also exist alone in a certain machine (as shown in the figure6), such a machine can be called a stand-alone server, and multiple stand-alone servers can form a server group 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 PHP language.

(6)B/SThe specific process of program work (as shown in the figure7)

(7) PHP The specific process of program work

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

Users request PHP files from the server through the browser (for example, enter in the address bar: http://localhost/index.php), ApacheLook for the PHP file requested by the browser in the user document publishing directory on the server. If it is not found, return an error message to the browser, otherwise, submit it to The PHP interpreter interprets and executes the PHP interpreter for the PHP file. Syntax analysis, if a syntax error is found, the error message (represented by a code that the browser can recognize) will be returned to the browser via Apache, otherwise the PHP will be executed program (may include operations on database MySQL) , will PHPThe program execution result (represented by a code that the browser can recognize) is returned to the browser via Apache. The browser interprets and executes the returned result, and the execution result 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 requested by the browser in the user document publishing directory on the server If the JavaScript file is not found, an error message will be returned to the browser. Otherwise, it will be returned to the browser. The browser will interpret and execute the returned results, and the execution results will be displayed in the browser window. middle.

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 input data

B. Send user data to server

C. Receive the response returned by the server

D.Explain 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

HTMLHyper Text Markup Language , hypertext markup language.

At the end of the

20 century80, at the European Particle Physics Laboratory (CERN:

HTTP: Hypertext Transport Protocol), used to obtain hyperlink files; use the Uniform Resource Locator (URLUniform 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)

http://www.bkjia.com/PHPjc/931894.htmlwww.bkjia.com

true

http: //www.bkjia.com/PHPjc/931894.html

TechArticle

Web program working principle, web working principle 1. Web program working principle (1) The meaning of the word Web Network: [Computer] Computer network, Web: [Computer] World Wide Web (WorldWid...
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