2023年全國碩士研究生考試考研英語一試題真題(含答案詳解+作文范文)_第1頁
已閱讀1頁,還剩8頁未讀 繼續(xù)免費閱讀

下載本文檔

版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領

文檔簡介

1、<p><b>  中文3670字</b></p><p><b>  外文原文</b></p><p>  Setting Up the PHP Development Environment</p><p>  Getting a working development environment put tog

2、ether can be intimidating, especially for the absolute beginner.</p><p>  To follow along with the project in this book, you’ll need to have access to a working installation of Apache, PHP, and MySQL, prefer

3、ably on your local machine. It’s always desirable to test locally, both for speed and security. Doing this both shelters your work-in-progress from the open Internet and decreases the amount of time spent uploading files

4、 to an FTP server and waiting for pages to reload.</p><p>  Why You Need Apache, MySQL, and PHP</p><p>  PHP is a powerful scripting language that can be run by itself in the command line of any

5、 computer with PHP installed. However, PHP alone isn't enough in order to build dynamic web sites. To use PHP on a web site, you need a server that can process PHP scripts. Apache is a free web server that, once inst

6、alled on a computer, allows developers to test PHP scripts locally; this makes it an invaluable piece of your local development environment.</p><p>  Additionally, dynamic websites are dependent on stored in

7、formation that can be modified quickly and easily; this is the main difference between a dynamic site and a static HTML site. However, PHP doesn’t provide a simple, efficient way to store data. This is where a relational

8、 database management system like MySQL comes into play. This book’s examples rely on MySQL; I chose this database because PHP provides native support for it and the database is free, open-source project.</p><p

9、>  It runs in both 32-bit and 64-bit environments, but on Windows the only official distribution is 32-bit, requiring Windows 32-bit compatibility mode to be enabled while using IIS in a 64-bit Windows environment. Th

10、ere is a third-party distribution available for 64-bit Windows. PHP is a general-purpose scripting language that is especially suited for web development. PHP generally runs on a web server, taking PHP code as its input

11、and creating web pages as output. It can also be used for command-</p><p>  At the time I write this, PHP 5.2.9 is the latest stable release available, but versions 5.3 and 6 are both scheduled for release i

12、n the near future. PHP 4 is still in use on a number of servers, but support has been discontinued. Many hosting companies let developer use either PHP 4 or PHP 5 on their sites.</p><p>  PHP Origin</p>

13、;<p>  PHP originally stood for “Personal Home Page” and was released as a free, open source project. It began in 1994 as a set of Common Gateway Interface binaries written in the C programming language by the Dan

14、ish/Greenlandic programmer Rasmus Lerdorf. Lerdorf initially created these Personal Home Page Tools to replace a small set of Perl scripts he had been using to maintain his personal homepage. The tools were used to perfo

15、rm tasks such as displaying his résumé and recording how much traffic his </p><p>  How PHP Works</p><p>  PHP is generally used as a server-side scripting language; it is especially w

16、ell-suited for creating dynamic web pages. The scripting language features integrated support for interfacing with databases such as MySQL, which makes it a prime candidate for building all manner of web applications, fr

17、om simple personal web sites to complex enterprise-level applications. Unlike HTML, which is parsed by a browser when a page loads, PHP is preprocessed by the machine that serves the document (this machi</p><p

18、>  Serving web pages with Apache HTTP Server is the most popular web server on the web; it hosts nearly half of all web sites that exist today. Apache is an open-source project that runs on virtually all available ope

19、rating systems.1 Apache server is a community-driven project, with many developers contributing to its progress. Apache’s open-source roots also means that the software is available free of charge, which probably contrib

20、utes heavily to Apache’s overwhelming popularity relative to its c</p><p>  Installing PHP</p><p>  Apache, and MySQL (the Hard Way).One of the biggest hurdles for new programmers is starting. B

21、efore you can write your first line of PHP, you must first download Apache and PHP, and usually MySQL, and then fight through installation instructions that are full of technical jargon you might not understand yet. This

22、 experience can leave many developers feeling unsure of themselves, doubting whether they have installed the required software correctly. In my own case, this hurdle kept me from learnin</p><p>  Fortunately

23、, the development community has responded to the frustration of beginning developers with several options that take all the pain out of setting up your development environment, whether you create applications for Windows

24、, Mac, or Linux machines. These options include all-in-one solutions for setting up Apache, MySQL, and PHP installations. The most common all-in-one solution is a program called “XAMPP”, which rolls Apache, MySQL, PHP, a

25、nd a few other useful tools together into one eas</p><p>  Keywords and Language syntax</p><p>  As with many scripting languages, PHP scripts are normally kept as human-readable source code, ev

26、en on production web servers. In this case, PHP scripts will be compiled at runtime by the PHP engine, which increases their execution time. PHP scripts are able to be compiled before runtime using PHP compilers as with

27、other programming languages such as C (the language PHP and its extensions are written in). Code optimizers</p><p>  PHP is similar to most high level languages that follow the C style syntax. If conditions,

28、 for and while loops, and function returns are similar in syntax to languages such as C, C++, Java and Perl. PHP stores whole numbers in a platform-dependent range. This range is typically that of 32-bit signed integers.

29、 Unsigned integers are converted values in certain situations; this behavior is different from other programming languages. Integer variables can be assigned using decimal (positive and nega</p><p>  Server-

30、Side vs. Client-Side Scripting</p><p>  The Internet features two main kinds of scripting: server-side and client-side. Client-side scripting is comprised mainly of JavaScript, which is responsible for many

31、of the web features that you can actually see happening, such as pop-up windows, some animations, and other site features like drop-down menus. The reason this is called “client-side” scripting because the code is execut

32、ed on the user’s machine, after the page has been loaded. Using client-side scripts enables you to make changes t</p><p>  Server-side scripting is performed on the site`s hosting server before the page is d

33、elivered to the user. This means that any changes that must be made by the script require a page refresh. Using server-side scripting is great for user authentication, saving changes to database information, retrieving e

34、ntries for display, and many other tasks. The downside of server-side scripts lies mainly in the required page refresh. Because the script is processed before it is delivered to the browser, the u</p><p><

35、;b>  中文翻譯</b></p><p><b>  設置PHP開發(fā)環(huán)境</b></p><p>  對于一個不折不扣新手來說,將一個工作中的開發(fā)環(huán)境放在一起是可怕的。</p><p>  隨著這本書的章節(jié),你將學習到在你本地機器上正確安裝運行Apache、PHP和 MySQL。它經(jīng)常需要在本地測試速度和安全性。這樣做既可以

36、保護你的開發(fā)中的版本免于受到開放式互聯(lián)網(wǎng)的威脅并縮短往一個FTP服務器上傳文件并且等待頁面重新載入所需要的時間。</p><p>  為什么你需要Apache,MySQL和PHP</p><p>  PHP是一種功能強大的腳本語言,它可以在任何已安裝PHP的電腦上通過命令行自行運行。然而,PHP本身是不足以建立動態(tài)網(wǎng)頁的。要想在網(wǎng)站上使用PHP,你需要一個可以處理PHP腳本的服務器。 Ap

37、ache是一個免費的服務器,一旦安裝在計算機上,開發(fā)人員能可在本地測試PHP腳本,這使得它成為你的開發(fā)環(huán)境中十分重要的一部分。 </p><p>  此外,動態(tài)網(wǎng)站依賴的可快速、輕易修改地存儲信息,這是一個動態(tài)網(wǎng)頁和一個靜態(tài)HTML網(wǎng)頁之間的主要區(qū)別。然而,PHP不提供一種簡單,高效的方式來存儲數(shù)據(jù)。這時一個關系型數(shù)據(jù)庫管理系統(tǒng)如MySQL發(fā)揮了作用。本書的例子基于MySQL。我選擇該數(shù)據(jù)庫是因為PHP對它提供本

38、地支持和該數(shù)據(jù)庫是免費的開源的項目。</p><p>  它在32位和64位環(huán)境下都能運行,但Windows環(huán)境下唯一的官方分布版本是32位,當在Windows 64位環(huán)境下使用IIS服務器時需要設置成Windows 32位兼容模式。也有支持 64位Windows環(huán)境的第三方發(fā)布版本。PHP是一種通用的腳本語言,特別適合于Web開發(fā)。PHP通常運行在一臺Web服務器上,以PHP代碼為輸入并創(chuàng)建網(wǎng)頁作為輸出。它也可

39、以應用于命令行腳本和客戶端GUI應用程序。PHP可以配置在大多數(shù)的Web服務器上,多種操作系統(tǒng)和平臺上并可以和多種關系型數(shù)據(jù)庫管理系統(tǒng)配合使用。它是免費提供的,PHP團隊提供完整的源代碼供用戶創(chuàng)建,定制和擴展他們自己使用。PHP主要作為一個過濾器,從文件或包含文本和/或PHP指令的流中提取輸入,然后輸出其它的數(shù)據(jù)流。最常見的輸出是HTML。它可以自動檢測用戶的語言。從PHP 4開始,PHP解析器編譯輸入,并產(chǎn)生字節(jié)碼供Zend引擎處理的

40、,提高了其編譯器預處理器的性能。</p><p>  在我寫這篇文章時,PHP 5.2.9是最新的穩(wěn)定版本,但PHP 5.3和PHP 6計劃在不久的將來發(fā)布。PHP4仍然在一定數(shù)量的服務器上使用,但已經(jīng)停止了對它的支持。許多托管公司讓開發(fā)者在他們的網(wǎng)站上使用PHP 4或PHP 5。</p><p><b>  PHP的起源</b></p><p&g

41、t;  PHP最初代表“個人主頁”并是一個免費開源的項目。它開始于1994年,是丹麥/格陵蘭程序員雷斯莫斯·勒道夫用C編程語言編寫的一個通用網(wǎng)關接口二進制文件集。 勒道夫最初創(chuàng)建這些個人主頁工具來取代一小部分Perl腳本,他一直用該腳本來維護他的個人主頁。這些工具用于執(zhí)行任務,例如顯示他的簡歷和記錄訪問他頁面的流量。他這些二進制文件和表單解釋器結合起來創(chuàng)建具有更多功能的PHP / FI。PHP / FI包括了一個更大的C編程語

42、言實現(xiàn),可以和數(shù)據(jù)庫進行通信,創(chuàng)建簡單的,動態(tài)Web應用程序。勒道夫在1995年6月8日公開發(fā)布PHP,加快錯誤定位,提高代碼性能。該版本被命名為PHP 2,并已經(jīng)具有了當今PHP版本所擁有的基本功能。這包括類Perl變量,表格處理,以及嵌入HTML網(wǎng)頁的能力。其語法與Perl類似,但比較有限,更簡單且不太一致。澤夫·蘇拉斯基和安迪·古曼茲,兩位在以色列理工學院的以色列開發(fā)者于1997年重寫了改分析器,形成了PHP

43、3的基礎,將該語言的名稱改為遞歸縮寫PHP:超文本預處理器。經(jīng)過幾個月的測試版測試后,開發(fā)團隊在1997年11月正式發(fā)布PHP / FI 2。后來,PHP 3</p><p><b>  PHP是如何工作的</b></p><p>  PHP通常被作為一個服務器端腳本語言,它特別適合用于創(chuàng)建動態(tài)網(wǎng)頁。該腳本語言的特征是集成了支持與數(shù)據(jù)庫的交互,如MySQL數(shù)據(jù)庫,這使

44、它成為所有創(chuàng)建Web應用程序方式中首要候選方式,從簡單的個人網(wǎng)站到復雜的企業(yè)級應用程序。與HTML當頁面加載時由瀏覽器解析不同,PHP由為文件提供服務的機器進行預處理(該機器通常指一個服務器)。在該文件被發(fā)送到訪問者的瀏覽器之前,該文件中所有包含的PHP代碼由服務器進行處理。PHP是一種腳本化語言,這是PHP程序員另一個巨大的優(yōu)勢。許多編程語言需要將文件編譯成機器代碼然后才可以運行,這是一個耗時的過程。繞過編譯意味著你能夠更快地編輯和測

45、試代碼。因為PHP是一種服務器端語言,在本地計算機上運行PHP腳本需要在本地機器上也安裝一個服務器。在這本書中的例子都是依的Apache Web服務器來傳遞你的網(wǎng)頁。</p><p>  提供Web頁面的Apache服務器是網(wǎng)絡上最流行的Web服務器,它承載今天存在的所有網(wǎng)站的近一半。Apache是一個開源項目,真實地運行在所有可訪問的操作系統(tǒng)上。 Apache服務器是一個團體驅動的項目,許多開發(fā)者為其進步作出貢

46、獻。Apache開源的性質也意味著該軟件是免費提供的,這可能有助于Apache對其競爭對手有壓倒性的優(yōu)勢,包括微軟的IIS和谷歌的GWS等等。在Apache的網(wǎng)站(www.apache.org)上,Apache HTTP服務器被描述成“努力開發(fā)和維護一個開源的HTTP服務器,用于現(xiàn)代的操作系統(tǒng),包括UNIX和Windows NT。該項目的目標是提供一個安全、高效和可擴展的服務器,它提供在與當前HTTP標準同步的HTTP服務。</p

47、><p><b>  安裝PHP</b></p><p>  Apache和MySQL的啟動是新程序員的最大障礙之一。當你要PHP來寫第一行程序時,你必須先下載Apache和PHP通常還有MySQL。然后按照安裝說明進行安裝,說明上可能都是你不明白的技術術語。該經(jīng)歷可以讓許多開發(fā)者不相信他們自己,懷疑他們是否已經(jīng)正確安裝了所需的軟件。就我自己來說,這個困難使我遠離學習編程

48、幾個月,甚至我拼命想去擺脫HTML。在這期間我在我自己的電腦上安裝PHP失敗了不止一次,整整三次后,我才讓成功運行我的第一個PHP命令。</p><p>  幸運的是,軟件的開發(fā)團隊已經(jīng)回應了初學者的困境。通過設置幾個簡單選項就可就可以使你免除設置開發(fā)環(huán)境的痛苦,不管你是為Windows,Mac還是Linux機器創(chuàng)建應用程序。這些選項包括一體化的用來設置Apache,MySQL和PHP安裝的解決方案。最常見的一體

49、化的解決方案是一個名為“XAMPP”的程序,集成了Apache、MySQL、PHP和其他一些有用的工具的安裝程序。XAMPP是免費的,可用于Windows,Mac和Linux,所以這本書假定你使用它作為你的開發(fā)環(huán)境。</p><p><b>  關鍵字和語言語法</b></p><p>  和許多腳本語言一樣,PHP腳本通常由人類可讀的源代碼組成,甚至在Web服務器。

50、在這種情況下,PHP腳本將在運行時通過PHP引擎編譯,從而增加了他們的執(zhí)行時間。 PHP腳本也可在運行之前和其他編程語言通過使用PHP編譯器編譯,比如C代碼優(yōu)化器。</p><p>  PHP與大多數(shù)遵循C風格語法的高級語言。如有條件,for和while循環(huán)以及函數(shù)返回和一些語言的語法類似,如C、C + +、Java和Perl。PHP的整數(shù)存儲在一個與平臺相關的范圍。此范圍通常是32位有符號整數(shù)。無符號整數(shù)在特定

51、情況下進行轉換。該行為與其他編程語言不同。整形變量可以分配使用十進制(正數(shù)和負數(shù))、八進制和十六進制符號。浮點數(shù)也存儲在一個特定平臺的范圍。它們可以通過使用浮點符號區(qū)分,或使用兩種形式的科學記數(shù)法。PHP提供了一個原生布爾類型,類似于Java和C++中的原生布爾類型。通過布爾類型轉換規(guī)則,非零值的數(shù)被翻譯成“真”,零被翻譯成“假”,</p><p>  就像Perl 和 C++一樣。、空數(shù)據(jù)類型表示的一個變量沒有

52、值。在空數(shù)據(jù)類型唯一的值是NULL。“資源型”的變量代表從外部來源引用的資源。這些通常是由一個來自特定擴展函數(shù)創(chuàng)建,只能由來自同一擴展的函數(shù)處理。例子包括文件,圖片和數(shù)據(jù)庫資源。數(shù)組可以包含任何PHP可以處理的類型的元素,包括資源,對象元素,甚至數(shù)組。PHP也支持字符,這些字符和單引號、雙引號和定界符一起使用。</p><p><b>  服務器與客戶端腳本</b></p>&

53、lt;p>  互聯(lián)網(wǎng)提供兩種主要的腳本:服務器端和客戶端??蛻舳四_本主要包括JavaScript,負責許多你可以真實看到發(fā)生的Web特性,如彈窗、一些動畫和其他的網(wǎng)頁功能,比如下拉菜單。之所以叫“客戶端”的腳本是因為頁面加載后該代碼在用戶的機器上執(zhí)行。使用客戶端腳本使你可以不用刷新頁面就可以更改頁面。它也有利于初始表單驗證,并簡化改進用戶接口。但是使用客戶端腳本需要用戶開啟JavaScript或它們的瀏覽器都支持你寫的腳本。這意味

54、著你不應該使用客戶端腳本來進行用戶認證或處理任何敏感事務,因為用戶能夠修改和/或禁用你的客戶端腳本。</p><p>  服務器端腳本在該頁面?zhèn)鬟f給用戶之前在該網(wǎng)站的托管服務器上執(zhí)行。這意味著通過該腳本進行的任何變化都需要刷新頁面。服務器端腳本更適用于用戶身份驗證、保存數(shù)據(jù)庫信息的變化、提取條目用于顯示以及許多其他任務。服務器端腳本的缺點主要在于需要的頁面刷新。因為腳本處理后才交付給瀏覽器,用戶沒有訪問權限進行內

55、部操作。這使得服務器端腳本成為處理任何敏感信息的最佳選擇。</p><p>  作者: Jason Lengstorf </p><p>  來源: PHP for Absolute Beginners:3-10</p><p><b>  詹森 蘭斯托</b></p><p><b>  PHP新手入門

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
  • 4. 未經(jīng)權益所有人同意不得將文件中的內容挪作商業(yè)或盈利用途。
  • 5. 眾賞文庫僅提供信息存儲空間,僅對用戶上傳內容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
  • 6. 下載文件中如有侵權或不適當內容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論