How Web programs work

Source: Internet
Author: User
Tags php language

How 1.WEB programs work

(1) meaning of the word Web

Network: "Computer" computer networks, net

Web: "Computer" www (WorldWide Web), Internet (Internet)

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

(2) Operating principle of stand-alone program

A single machine, a computer that is not connected to another computer, is not in the network. For example: Two stand-aloneA,B, only inAThe program is installed on theX, in order toBon gettingXrun results, you mustBinstall it again.X, and then run. IfBClass of computers, you need to install them individually. There is no direct communication and collaboration between them. 1is shown.

(3) How the client / Server program works

Connecting a single machine to a network, such asAwith theBNetwork, you can provide services between them, such as theAtoBprovide services. The common service is file sharing,FTPfile download and so on. We call the computer that provides the (response) service the server (Server), the computer that accepts (requests) the service is called a client (Client), also called workstations (Workstations). Client/how the server program works2is shown.

The roles of the server and the client can be converted. A computer that can provide services to itself, when it is both a server and a client. For example, if computer a shares its own folder a and then finds aon the network, youcan download A, You provide services to yourself, you request and respond to the service.

Client / Server collaboration between computers, called C/S mode, or C/ s architecture.

the C/s program is divided into two parts: server-side and client-side, which are called server-side programs (or service programs) and client programs (or client programs). For the client program, for each client, also have to install separately, this is the same as the distribution of the single-machine program, is also very troublesome. However, after the client program is installed, it is possible to interact with the server through the communication line, or through the server, to communicate with other clients. The typical example is the chat program QQ, which is commonly used by everyone ,3 shows.

(4) How the browser / Server program works

If through the client browser (Browser), to the server to make a request to receive the results of its response, then, we call this collaboration mode b/ s , or b/S schema, which works as 4:

At this point, the client program is the browser, and the installation of the browser with the operating system is completed, do not require additional user installation. For them, the use of B/S program (such as the internet to watch news, send and receive e-mail), you do not need to install a dedicated client program, directly in the browser to operate. This makes the b/S program maintenance is very convenient, because no tube client program, as long as the maintenance of the server-side program can be.

(5) composition of C/S,b/S server

Server is the machine that is responsible for the service task. These service tasks are done by the general specialized software. Generally, the server software with a certain service function and the machine on which it resides are collectively referred to as xx servers (xx denotes a specific service). The software can be concentrated in a single machine (5), such a machine can be called a centralized server, or can be found in a single machine (6), such a machine can be called a stand-alone server, Multiple stand-alone servers can form a server farm or a matrix.

Following the service tasks, several common server software are shown in table 1.

Server-side scripting: programs written in the server-side programming language.

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

(6) b/S procedure work of the specific process (7)

(7) the specific process of PHP program work

The process is a collaborative process between Apache,PHP, and the browser:

The user requests the server through the browserPHPfile (for example, enter in the Address bar:http://localhost/index.php), Apachein the User document publishing directory on the server, look for the browser requested by thePHPfile, if it is not found, return an error message to the browser, otherwise, submit it toPHPThe interpreter interprets the execution,PHPinterpreter on thePHPfile for parsing, and if a syntax error is found, theApachereturns an error message (represented by a code that the browser can recognize) to the browser, otherwise executes thePHPprogram (which may contain databaseMySQLthe operation),will bePHPProgram execution results (expressed in code that the browser can recognize)Apacheback to the browser, the browser interprets and executes the returned results, and the results of the execution are displayed in the browser window.

If the browser is requesting a file that is not a PHP file, It is an HTML file or a JavaScript file . The process will be simplified:Apache finds the HTML file or JavaScript file requested by the browser under the User document publishing directory on the server . If it is not found, the error message is returned to the browser, otherwise it is returned to the browser, and the browser interprets, executes, and executes the results displayed in the browser window.

2. Browser work process

(1) Web Client working process

Any application system must have an interface that provides user action, that is, the user interface. The work of the browser, from the whole b/S program, is the user and b/S program dealing with an interface (interface). Its mission is to:

A. Collecting data entered by the user

B. Sending user data to the server

C. Response returned by the receiving server

D. Explain, execute the code

As you can see, the browser plays the role of a proxy (agent) for the server in the user. This agent has the function of collecting messages, requesting responses, and explaining the instructions that the server sends back.

(2) Web client code

Whether the interface that the organization uses to collect user data, or the instructions from the server to form the resulting interface, are implemented with WEB client code. Common Web client code is HTML language,JavaScript language,CSS, XML and other languages.

3.HTML Working principle

(1) introduction to HTML

HTML:Hyper text Markup Language , Hypertext Markup Language.

20century theat the end of the decade at the European Particle Physics Laboratory (CERN:The European labloratory for particle Physics)work ofTim Berners-lee(WWWThe father of the study found that people's visual processing is based on the page. So he came to the conclusion that electronic data should be presented in the form of pages. Taking this as the starting point, he uses hypertext-centric management to organize the information on the network, and proposes a method of establishing the access and browsing Web pages: The Hypertext Markup Language is established, and the Hypertext Transfer Protocol is designed.HTTP:Hypertext Transport Protocol), which is used to get the hyperlink file, using the Uniform Resource Locator (URL:Uniform Resource Locator)to locate a network file, site, or server.

(2)howHTML Works

HTML is not a programming language in nature, but a markup language. The so-called Mark, in some books also called tags, from an object-oriented point of view, is the meaning of the browser object identification. It is used to control the performance of text, images, and other browser sub-objects in the browser, as well as how to establish a link between files tags. These tags are placed in a text-formatted file. The biggest difference between programs is that they can be used to control the operating system or application to execute and complete a job. Hypertext Markup Language documents should be done as much as possible, formally, regardless of any operating system on any browser open has the same effect.

(3) basic structure of HTML

A. Version declaration, order (prologue)

B. Header (head)

C. Body (body)

How Web programs work

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.