How Web programs work-how web programs work-PHP Tutorial

Source: Internet
Author: User
Tags ftp file
The working principle of Web programs. Working principles of Web programs: 1. web program working principle (1) Web definition Network: computer Network, Web: computer the working principle of the World Wide Web program

1. how Web programs work

(1) meaning of the word Web

Network: computer Network, Network

Web: [computer] World Wide Web, 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 a php file from the server through a browser (for example, enter http: // localhost/index in the address bar. php). Apache searches for the php file requested by the browser under the user document release directory on the server. if the php file cannot be found, an error message is returned to the browser. otherwise, submit it to the PHP interpreter for explanation and execution. The PHP interpreter performs syntax analysis on the PHP file. if a syntax error is found, the error message is returned by Apache (indicated by the code recognized by the browser) go to the browser. otherwise, execute the PHP program (which may include operations on the MySQL database) and return the PHP program execution result (indicated by the code recognized by the browser) to the browser through Apache, the browser interprets and executes the returned results. The execution results are 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 the result to the browser. the browser interprets and executes the returned result. the execution result is 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: Hyper Text Markup Language, hypertext Markup Language.

At the end of 1980s, Tim Berners-Lee (father of WWW), working at CERN: the European Labloratory for Particle Physics, found that: people's visual processing is based on pages. 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: Hypertext Transport Protocol) is designed to obtain hyperlink files. a Uniform Resource Locator (URL: Uniform Resource Locator) is used to locate network files, sites, or servers.

(2) how HTML works

HTML is essentially not a programming language, but a markup language. Tags are also called tags in some books. from an object-oriented perspective, they mean the identification of browser objects. It is used to control the display of sub-objects of browsers such as text and images in the browser, and how to establish the mark of links between files. These tags are all stored in text files. The biggest difference between programs is that they can be used to control the operating system or application execution and complete a job. Documents in hypertext markup language should be as effective as possible. in terms of form, opening a document in any browser of any operating system has the same effect.

(3) Basic structure of HTML

A. version declaration, that is, Prologue)

B. Head)

C. Body)

1.Web program working principle (1) What is the term Web Network: [computer] computer Network, Web: [computer] World Wide Web (WorldWid...

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.