PHP learning book-Chapter 2

Source: Internet
Author: User
Tags php programming language what php
Servo Web Scripting language this chapter focuses on static dynamic Web page client and servo Scripting language comparison introduction to servo Scripting language this chapter focuses on the server Scripting language itself, it also talks about the Scripting language with static HTML and Servo Web.

Highlights of this Chapter
· Understanding static dynamic Web pages
· Comparison between the client and the servo Scripting language
· Introduction to the Scripting language on the servo end

This chapter focuses on the Scripting language on the server, and also on the relationship between it and static HTML and general client technology. At the end of this chapter, readers will be able to clearly understand what PHP can do, what it cannot do, and how it can communicate with the original user end.

Static HTML

The most basic form of Web pages is to write purely static and text pages in HTML. -A simple HTML page in-1 is an example.

Scripting language for the Servo Web

Highlights of this Chapter
· Understanding static dynamic Web pages
· Comparison between the client and the servo Scripting language
· Introduction to the Scripting language on the servo end

This chapter focuses on the Scripting language on the server, and also on the relationship between it and static HTML and general client technology. At the end of this chapter, readers will be able to clearly understand what PHP can do, what it cannot do, and how it can communicate with the original user end.

Static HTML

The most basic form of Web pages is to write purely static and text pages in HTML. -A simple HTML page in-1 is an example.

-1 static HTML webpage specification

The following is the original code OF-1:

As shown in 2-2, when the client computer makes an HTTP request to a page from the server through the Web or Intrantet, the server only needs to pass the plain text not found in the file.


When the information is sent back to the client computer, the browser performs the best resolution and presentation of the original code content, user preferences, display size, and other factors. The content of the HTML file on the server is exactly the same as the original code on the page on the client computer.

Your very common static HTML has the following advantages:

◆ Any browser can display it.

◆ Most devices have the ability to display it.

◆ It can quickly execute each request and only use the least amount of resources.

◆ HTML is easy to learn or automatically generated.

◆ Small changes can be made to individual pages quickly.

◆ Of course, static HTML also has the following disadvantages:

◆ Difficult to control design and layout configuration.

◆ Cannot be expanded to a large number of pages.

◆ Interaction is not good enough.

◆ It is not easy to include meaningful metadata about the page.

◆ It is not easy to cope with rapid changes in content or personalized information.

◆ Not very attractive.


Because... It can only be regarded as a "amateur" level or an ideal firm application (this ideal is determined by the web pages written by some computer science experts, and they think that all web pages should comply with the HTML3.1 specification and must be read by all devices ).

Many other technologies have been developed to address these limitations, including JavaScript, Cascading Style Sheet (CSS), and Java applets, it also includes the servo scripting language connected to the servo database. Developing technologies include XML and XSL, both of which are part of other specifications (XHTML, XSLT, XPath, and ICE.

If you spend some time learning about the features of these technologies and whether they can be added to your Web site, it will definitely reduce your chances of headaches. For any website task on hand, the first step is to first ask yourself the basic question: where is the computation executed, the user end or the servo end?

Dynamic involves a basic and repetitive difference between static and dynamic Web pages, but "dynamic" can represent almost everything except ordinary HTML. It is used to describe user-side functions and servo-side functions. On the user side, "dynamic" can be seen as multimedia display, rolling Title lines, automatically updated pages, or currently hidden elements ...... . At the servo end, this term is generally used to reference the content that is being transmitted in the air and interacted with the combination.

Client technology

For common HTML, the most common addition of content occurs on the user end. It includes the following aspects: CSS, Dynamic HTML, and other format extensions, user-side scripting language, Java applets, and Flash. The supported methods of these technologies are (most of which are supported) built in Web browsing. Table 2-1 lists their functions, partially overlapping.

Table 2-1 user-side HTML extension

The page examples listed in-3 and-1 are based on the same content.


As you can see from the original code, this example adds some style sheets, user-side scripting, and some complicated HTML codes.


Unfortunately, the best selling point of client technology is also the worst: they depend entirely on browsers. The functions of each browser vary greatly, even if different versions of the same brand are different. Each person can also choose to configure their own browsers in different ways. for example, some people may disable JavaScript due to security concerns, in this way, it is impossible for them to browse websites that over-use JavaScript for navigation. (If we have the function shown in the previous example)

In addition, many users suffer poor browser upgrade due to cost or technical insufficiency. Web developers should be familiar with device-based browsing, general and global users. Without exception, websites designed in the mass market are trying to obtain the widest range of users, such as Yahoo! With Amazon's adoption of these standards, it has been more than three years since they insisted on not using style sheets and JavaScript. Under W3C pressure, many websites are still stubbornly sticking to the FONT tag and BGCOLOR attributes, and their customers may be those who use AOL3.0 on older Macintosh machines on the 13-hour display. What's more ironic is that even after five years of rapid development of the Web, what developers can provide to customers is to let them see plain text-based HTML. (Or even a subset of HTML that has been easily tested by time)

Finally, the client technology cannot connect to any backend server. JavaScript cannot generate a custom drop-down list based on user preferences stored in the database. when the list needs to be modified, web developers must go to this page to manually modify (servo-side JavaScript, but not much is used currently). For this problem, the servo-side JavaScript language can fill this gap in the rescue.

In short, all actions to handle layout configuration or browser events occur on the user end. Generally, things that look cool or depend on moving the mouse are on the client. The faster an event is displayed, the more likely it is to be processed by the user end. the faster the event, the less download is required from the server.

Note:
Java applets, also known as "client-side Java (client-side Java)", is less dependent on browsers than other client technologies. As its name implies, they are a complete small Java application passed over the Internet, but they do not interact directly with the client's job system as applications written in other programming languages, java applets is executed on the intermediary software called JVM (Java Virtual Machine, Java Virtual host. JVM can be seen as a job system that exists on a real job system. Most of the latest browsers will not be able to make full use of JVM. of course, you can also download one by yourself. This sort of work makes it possible for the applet to make the browser play a special function without being limited by the browser's relatively weak capabilities.

In the early days, applets were considered meaningless because they were originally used to implement some simple mobile Books. for example, icons that look like transparent adhesive will scroll the title column, such as the beating key. Fortunately, the applet has changed and can be used for some humanistic purposes, such as crossword puzzles, Tower simulation, try-on clothes and accessories, and virtual methods.


Servo scripting language

-4 is the server scripting data process.

The user-side scripting language is very attractive and is not the most eye-catching part in normal Web development. The servo program design is the opposite. it is invisible to users and hidden behind them. The programmers at the servo-end scripting always try to find out between the materials on the back-end Web servers, while those who have art cells at the front-end can show their works in front of the masses.

The scripting language of the servo Web is mainly to connect W eb websites to backend servers, such as databases, which allows two-way communication:


The scripting language of the servo Web is mainly to connect W eb websites to backend servers, such as databases, which allows two-way communication:

◆ Server-to-Client: Web pages can be combined from backend server output.

◆ Client-to-server: enables the information entered by the client to take effect.

Common examples of client-to-server communication are online forms and drop-down lists dynamically combined on the server. (Usually you need to press the button ).

The servo-side scripting language product has two main parts: the scripting language and the scripting engine (which may be built into the Web server or not ). The engine is developed by the same company or team and can only be used together (PHP3 and ColdFusion are two examples ). However, there are exceptions to this rule. for example, Java Server Pages is written in standard programming languages rather than the scripting language for special purposes; some cooperation vendors have developed several interchangeable engines (such as Allaire JRun and Apache JServ ).

Theoretically, Active Server Pagesb allows one of the vast majority of scripting languages and several compatible ActiveX scripting engines (however, in practice, except for the combination of NT, IIS, VBScript, and JScirpt, there are many other combinations.) due to PHP4's scriptingz engine (Zend) at present, it is theoretically separated from the PHP programming language, so PHP4 is now a separate and independent scripting technology.

. 5. a simple example of the servo scripting language is listed. a page is generated from the database based on the original servo code and the original client code. We include a database call (I will not explain it in detail before Part II of this book), and omitted some inclusive files, because the purpose of this example is to display the final product of PHP, rather than being used as the executable original code of the formal job

The following are the original codes on the server:

This is the original code representation when the same page arrives at the user end:

The above is the content of chapter 2 of the PHP Learning Guide. For more information, see PHP Chinese website (www.php1.cn )!

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.