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

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領(lǐng)

文檔簡介

1、<p>  本科畢業(yè)設(shè)計(論文)</p><p>  外文參考文獻譯文及原文</p><p>  學(xué) 院 信息工程學(xué)院 </p><p>  專 業(yè) 信息工程(電子信息工程方向) </p><p>  年級班別 2004級(4)班

2、 </p><p>  學(xué) 號 3104002975 </p><p>  學(xué)生姓名 陳英權(quán) </p><p>  指導(dǎo)教師 劉喜英 </p><p&

3、gt;  2008 年 6 月 5 日</p><p><b>  目 錄</b></p><p><b>  外文參考文獻譯文</b></p><p>  1 為什么選擇PHP2</p><p>  2 如果你是編程新手4</p><p>  3 寫一個基本的PH

4、P程序4</p><p><b>  4 編程語法8</b></p><p>  5 嵌入式語言如何工作9</p><p>  6 服務(wù)端和客戶端腳本11</p><p>  7 運行你的程序13</p><p><b>  外文參考文獻原文</b></p&g

5、t;<p>  1 Why PHP?14</p><p>  2 If You Are New to Programming16</p><p>  3 Writing a Basic PHP Program18</p><p>  4 Programming Syntax21</p><p>  5 How Embed

6、ded Programming Works24</p><p>  6 Server-side Versus Client-side Scripting25</p><p>  7 Running Your New Program27</p><p>  1 為什么選擇PHP</p><p>  對于Web編程來說,PHP是一個很好的選

7、擇。它較其它語言(包括其它面向Web的語言)有許多優(yōu)點。為了得到一個清晰的理解(和常見的面向Web的語言相比),讓我們將它們比較一下。</p><p>  ASP是微軟的網(wǎng)絡(luò)開發(fā)環(huán)境(它本身不是一門開發(fā)語言,因為它允許程序員在ASP中選擇其它語言進行開發(fā),如VBScript或JScript。)ASP雖然簡單,但它太過于簡單了,以至于不能使用更復(fù)雜的邏輯和算法。</p><p>  除了AS

8、P的過分簡單,很多公司發(fā)現(xiàn)很難在微軟的ASP許可證上節(jié)約成本。即使不考慮硬件成本,微軟的Web服務(wù)器就要數(shù)千美元,而基于UNIX操作系統(tǒng)的、可運行PHP的Web服務(wù)器則是免費的。</p><p>  另一種Web使用的知名語言是Sun Microsystems公司的Java。Java是平臺獨立的語言(在一個系統(tǒng)上用Java開發(fā)的程序可以不經(jīng)過任何修改,就可以運行在其它系統(tǒng)上)。</p><p&

9、gt;  盡管Java的確有它的優(yōu)點,但它在開發(fā)時間、開發(fā)成本和執(zhí)行速度上卻有明顯的劣勢。Java開發(fā)是耗時的,因為Java工程要遵循嚴格的規(guī)則(Java強制的),這需要進行大量的規(guī)劃。另外,Java開發(fā)周期長,費用成本高, Java程序員的待遇也較高。因此Java程序開發(fā)的成本遠遠高于其它語言開發(fā)的成本。通過我們的比較可以看出,即使項目開發(fā)結(jié)束后,以Java語言寫的程序在運行時所花費的時間比其它語言的時間還要長。</p>

10、<p>  總的來說,和Java相比,PHP的表現(xiàn)很出色。一個相似的工程以PHP語言開發(fā),要比用Java開發(fā)節(jié)省兩三倍的時間。最重要的是,雖然最終的程序都可以運行多種平臺上(如Java),而PHP的程序則運行的更快。</p><p>  另一種開發(fā)Web程序的常用語言是Perl。Perl與PHP一樣,是一個可運行在多個平臺上的開源項目。事實上,Perl的歷史遠遠要比PHP長。在PHP之前,Perl被認

11、為是最好的Web開發(fā)語言。然而,在過去的幾年中,在Web開發(fā)領(lǐng)域,PHP贏得了比Perl更好的口碑。因為PHP語言本身集成了大量的功能模塊,而要在Perl中使用這些功能,你就不得不單獨下載許多額外的功能模塊。這樣,當程序從一個系統(tǒng)轉(zhuǎn)移到另一個系統(tǒng)時,就會容易產(chǎn)生問題,因為Perl不得不從自己的CPAN上下載相應(yīng)的功能模塊。</p><p>  最后要比較的語言是C。C語言已經(jīng)存在很長的時間了;它已被用在各種各樣的

12、計算機中,從大型主機到個人PC都可見到它的身影。如果你了解C語言的話,你就會知道用C語言開發(fā)Web程序會存在一些問題。為了用C語言開發(fā)一個Web程序,在你著手構(gòu)思你的實際任務(wù)時,你將不得不著手實現(xiàn)所有Web程序本身就應(yīng)該具備的功能(如采集HTML表單提交的數(shù)據(jù))。而PHP語言提供了所有的Web常用或者并不是很常用的功能,可以允許程序員將更多的精力放在實際的任務(wù)中。</p><p>  就其它的Web開發(fā)語言與PH

13、P語言之間的比較而言,它們之間還存在很多不同。在Internet上將PHP與Java,Perl,ASP等語言進行比較的文章也很多。但是一旦你擁有了PHP的編程經(jīng)驗,你可能就會發(fā)現(xiàn),在選擇開發(fā)語言時,你會努力的說服你的客戶或老板,允許你使用PHP來進行開發(fā),而不是選擇其它的語言。如果出現(xiàn)問題,你可以通過搜索Internet找到大量基于這些問題的有用信息。</p><p>  PHP的使用是沒有限制的。早期的版本使用

14、的是單獨的跟蹤程序。而隨著時間的推移,這個簡單的跟蹤程序已經(jīng)被包含在語言的內(nèi)部了。</p><p>  PHP的主要用途,當然不只是用來跟蹤的了;它還可以做許多其它的事情。為了讓你理解PHP可以做什么,下面介紹了一些PHP的常見用途:</p><p><b>  反饋表單</b></p><p>  購物車和其它類型的電子商務(wù)系統(tǒng)</p&

15、gt;<p>  用戶注冊,訪問控制,以及在線訂閱服務(wù)</p><p><b>  客戶登記</b></p><p><b>  討論和留言板</b></p><p><b>  如果你是編程新手</b></p><p>  如果你是一個從來沒有寫過程序的新手,這

16、個想法可能有點嚇人。大多數(shù)程序員可能會告訴你(如果他們愿意承認),他們剛開始學(xué)習(xí)編程的時候,也有點無從下手。然而,編程的過程根本不是那么難,相反卻很享受,因為你不需要有多高的智商來適應(yīng)它。</p><p>  當你寫程序的時候,你的主要目的就是把你的想法翻譯成計算機能夠識別的語言。例如,如果你是教人如何做漢堡包,你會首先描述將牛肉做成牛肉餅的過程。然后,你會告訴他如何把漢堡包放在烤架上,烤多長時間,最后,如何把它

17、們拿下來。</p><p>  當然,僅僅因為你能描述制作漢堡包的過程,并不意味著PHP能夠在任何時間、任何地點為你做任何事情。重點是,如果你能像我剛才描述制作漢堡包的過程那樣,描述你的想法及思路,你就可以寫程序。</p><p>  寫程序的過程就是告訴PHP如何做事情的過程。當你讀完本文的時候,你就會明白圍繞在PHP程序背后的所有概念,這些概念就像描述制作漢堡包的過程一樣。對于本文,你

18、讀的越透,你明白的概念就越多,你向PHP描述的任務(wù)就越準確。因此,如果你很快學(xué)會用PHP程序來實現(xiàn)你的需求和想法,你就不會再感覺到煩惱了。</p><p>  整體說來,有些編程問題可能是非常復(fù)雜的。例如,創(chuàng)建一個購物車,那并不是一個簡單的事任務(wù)。然而,你可以將這個大任務(wù)分成幾個小任務(wù)。這些小任務(wù)可能僅僅包括添加和刪除的操作,而添加和刪除的操作還可以被分解成更小的任務(wù)。你可以看到,不管任何任務(wù),無論它有多復(fù)雜,只

19、要可以分解,分解后的任務(wù)簡單到不需要再對它進行分解了,你就可以實現(xiàn)這個任務(wù)。當你創(chuàng)建更復(fù)雜的程序時,你就會對這個過程有更加細致的體會了。</p><p>  寫一個基本的PHP程序</p><p>  在我們開始寫一個實際程序的時候,要看看創(chuàng)建程序的步驟。這些步驟并不復(fù)雜;實際上,這個過程和你創(chuàng)建一個HTML頁面,并將它同步到你的服務(wù)器上的過程基本一致。</p><p&

20、gt;  和創(chuàng)建一個HTML頁面不同,創(chuàng)建一個PHP程序,你要面對的是文件中的代碼,而不是那些所見即所得(WYSIWYG)的內(nèi)容。如果你要利用這些所見即所得的編輯器開發(fā)程序(如微軟的FrontPage,Macromedia Dream-Weaver,微軟Word等),你可能還要花費一些時間來研究代碼。</p><p>  但令人興奮的是,沒有人也沒有任何理由要求你,不能使用所見即所得的編輯器來編輯程序。然而,你可

21、能會失望的發(fā)現(xiàn),許多所見即所得的編輯器會修改或刪除PHP文件中的代碼。積于這個原因,分析你的編輯器是如何處理PHP代碼的,這很重要。如果你想用你的編輯器來進行這種測試,要先創(chuàng)建一個新文件,保存,后綴名為.php。然后,切換到編輯器的源碼視圖,或在一個獨立的其它編輯器中打開這個文件(如記事本等),輸入接下來本文要引用的代碼,并確保沒有任何錯誤。</p><p>  當你輸入完成后,保存文件并切換回WYSIWYG編輯

22、器視圖。如果你看到你的PHP代碼,不用管它,繼續(xù)鍵入幾行文字。如果你想添加一些Web頁面中常用的元素,如表格和圖片等,就請繼續(xù)插入這些內(nèi)容,保存,并關(guān)閉WYSIWYG編輯器。</p><p>  現(xiàn)在,在記事本中打開該文件,看看你的PHP代碼是否發(fā)生了變化,包括代碼格式上的改變,特殊字符的轉(zhuǎn)換(如< &lt;)以及完全被刪除的代碼。</p><p>  你可能會發(fā)現(xiàn)PHP代碼

23、被以某種方式改變了。因為PHP代碼對一些WYSIWYG編輯器導(dǎo)致的變化是敏感的,如果你在寫PHP代碼的時候,使用WYSIWYG編輯器,這就很難讓人理解了。PHP社區(qū)不會因為這個原因,而建議你不要使用WYSIWYG編輯器,因為使用這樣的編輯器有時還是可以加快程序的開發(fā)速度的。</p><p>  現(xiàn)在,當你讀代碼或者測試本文中的程序時,請試著習(xí)慣使用這些純文本編輯器吧。當你習(xí)慣使用純文本編輯器的時候,再使用其它的編

24、輯器,那就容易上手的多了。到那時,你就可以識別出編輯器自身生成的代碼,也就能更容易的找出提高你工作效率的方法了。</p><p>  不管你現(xiàn)在處理PHP代碼的編輯器是什么,如果你正在用的是WYSIWYG編輯器,我建議你使用如記事本這樣的純文本編輯器,或者一些帶有語法加亮功能的純文本編輯器。這些編輯器可以保證你的代碼就像剛輸入時的一樣(WYSIWYG編輯器傾向于以它自己的規(guī)則來格式化你的代碼,而這種功能對于編輯P

25、HP代碼來說并不需要)。即使你的編輯器沒有改變你的PHP代碼,但如果它不是一個嚴格基于文本的編輯器,仍然會在隨后的運行中可能會出現(xiàn)問題。</p><p>  這是創(chuàng)建和瀏覽HTML文件的一般過程:</p><p>  1.創(chuàng)建HTML文件(添加文本,表格,圖像,或聲音等)。</p><p>  2.保存HTML文件,命名為filename.html。</p&g

26、t;<p>  3.用FTP程序把你的文件上傳到Web服務(wù)器。</p><p>  4.用你的瀏覽器訪問Web服務(wù)器上的文件(如,http:/ / www.example.com /filename.html)。</p><p>  創(chuàng)建PHP程序的過程大致與創(chuàng)建HTML文件的過程相同:</p><p>  1.創(chuàng)建HTML文件(包含文字,表格,圖像,

27、或聲音),并在適當?shù)奈恢貌迦隤HP代碼。</p><p>  2.保存PHP文件,命名為filename.php。</p><p>  3.使用FTP程序上傳你的文件到Web服務(wù)器。</p><p>  4.用你的瀏覽器訪問Web服務(wù)器上的文件(如http:/ / www.example.com /filename.php)。</p><p>

28、;  可見,創(chuàng)建PHP程序和創(chuàng)建常規(guī)HTML程序的過程沒有多大不同。</p><p>  在了解了創(chuàng)建PHP程序的大致過程后,請看一下你的第一個PHP程序??催^代碼你將了解,如何將PHP文件與普通的HTML文件相區(qū)分,如何把它上傳到你的Web服務(wù)器上,以及在瀏覽器中頁面看起來應(yīng)該是什么樣的。</p><p>  <!-- File: filename.php --></p

29、><p><b>  <html></b></p><p>  <head><title>PHP </title></head></p><p>  <body bgcolor=”white” text=”black”></p><p>  <h4

30、>PHP</h4></p><p><b>  <?php</b></p><p>  /* Display a text message */</p><p>  echo “Hello, world! This is my first PHP program.”;</p><p><b&

31、gt;  ?></b></p><p><b>  </body> </b></p><p><b>  </html></b></p><p>  這個文件看起來和一個普通的HTML文件很像。注意,文件中包含了典型的HTML標簽。事實上,如果你忽略<?php 和 ?>

32、標簽間的內(nèi)容,你也可以把該文件重新命名為.html的后綴名。</p><p>  然而,這個文件的確包含了PHP代碼,所以它必須被命名為.php后綴名。PHP代碼在兩個PHP標簽之間((<?php 和 ?>)),如圖1.1所示。PHP標簽之間的命令是“echo”(PHP的關(guān)鍵字,意思是“顯示文本”)隨后跟的是要顯示的文本。結(jié)果很快被顯示出來,“echo”后面的文本看起來就像是包含在HTML文件本身一樣

33、,似乎就沒有PHP代碼存在過。</p><p>  圖1.1:這幅圖顯示了一個基本的PHP程序的不同部分。</p><p>  在看輸出的結(jié)果之前,我們先把這個文件上傳到Web服務(wù)器上并且運行。按照上面寫PHP程序的過程,將它保存為PHP文件(.php后綴名),并上傳到你的Web服務(wù)器。</p><p>  一旦你的程序被上傳到您的Web服務(wù)器,在你的瀏覽器中輸入該

34、文件地址。你應(yīng)該得到一個返回的頁面,它看起來應(yīng)該非常類似如下的截圖。</p><p>  圖1.2:當你訪問你的程序時應(yīng)該看到這樣的頁面。</p><p><b>  編程語法</b></p><p>  當你訪問剛剛上傳的PHP程序時,該PHP程序在返回瀏覽器之前是經(jīng)歷了一個復(fù)雜的過程的。PHP文件中的相關(guān)命令就是在這個過程中被執(zhí)行的;在這個

35、例子中,是一個單獨的echo語句。圖1.3顯示當PHP文件發(fā)送請求時歷經(jīng)的過程。</p><p>  圖1.3:不像HTML文件,PHP文件在被返回瀏覽器時執(zhí)行了文件中包含的PHP命令。</p><p>  PHP解釋器(或解析器)程序,正如上圖中看到的那樣。它讀取PHP程序并執(zhí)行它所能理解的命令。(如果PHP碰巧遇到一個它不能理解的命令,它會停止繼續(xù)解析該文件,并返回一個錯誤消息給瀏覽器

36、。)</p><p>  每當PHP在給Web服務(wù)器發(fā)送請求時,該PHP解釋器在給瀏覽器反饋信息前,必須先處理PHP文件中的命令。因為PHP的每次運行,都必須調(diào)用相關(guān)的例程,以便執(zhí)行這些命令。</p><p>  這和編譯型語言有所不同,如C或C + +,它們只被解釋一次;C語言程序,直接被翻譯成機器碼(機器碼直接由CPU處理)。PHP不得不解釋程序中包含的命令,這些命令還在必須以PHP能

37、夠識別的形式給出。例如,如果有人走向你,用德語詢問時間,你可能不知道他在說什么(除非你懂得德語或者這個人指著他的手腕)。同樣地,如果我走到你面前說,用英文語美味問你,“現(xiàn)在幾點了?“你可能也不知道我在說什么。</p><p>  PHP也有類似的限制。語句(命令的集合,由特定字符組成,PHP能夠識別的句子)必須以正確的命令格式給出。例如,你要在PHP中顯示一條文本,你必須使用PHP能夠識別的命令,如“echo”。

38、同時,你必須把你的單詞,以正確的順序,用英語講給別人。還要格式化要傳遞給PHP執(zhí)行的語句,以便PHP解釋器能夠識別并執(zhí)行。</p><p>  語法,就是將PHP能夠理解并執(zhí)行的句子組織到一起的過程中要遵循的規(guī)則,這就是PHP的開始和結(jié)束標簽。PHP只解析在PHP標簽之間的代碼。而不在這其中的代碼只是作為HTML頁面的一部分返回,正如先前看到例子一樣。</p><p>  如下這個例子,該

39、語句不能執(zhí)行,即使該命令是PHP語言的命令:</p><p>  echo “This won’t work.”</p><p>  該語句不會執(zhí)行,因為它沒有遵循所有的語句必須以分號結(jié)尾的基本語法規(guī)則。一些特殊的語句不需要有分號,但不是很多(如do語句。)注意,PHP語句必須以分號結(jié)束。下面的語句能夠正確執(zhí)行并輸出:</p><p>  echo “This wo

40、rks!”;</p><p>  你可能注意到了,即使兩個語句在同一行,但語句間并沒有分號分隔,PHP并不會報錯。這是PHP的一個特性,它使得插入一個單獨的echo語句變得更加容易。如果你想在第一個echo語句運行后看到返回的錯誤提示,那么將這兩個語句輸出到不同的行,看起來就像這個樣子:</p><p>  echo “This won’t work.”</p><p&

41、gt;  echo “This won’t work.”</p><p>  代碼不會運行,PHP將返回一個錯誤信息,因為沒有分號來分隔這兩個語句。</p><p><b>  嵌入式語言如何工作</b></p><p>  通過前面的講解,我們知道PHP代碼必須封裝在<?PHP和?>這兩個 PHP標簽之間。在同一文件中,使用標簽來

42、分隔PHP代碼和HTML代碼,這就允許將PHP代碼要處理的信息和HTML要顯示的信息直接混合在一起。這使得PHP成為一種嵌入式編程語言,因為PHP代碼被直接嵌入在HTML代碼中了。</p><p>  這個概念是相對較新的:在PHP語言出現(xiàn)之間,并沒有程序要像HTML這樣復(fù)雜的格式化顯示的需求。顯示在屏幕上的信息通常只是字母,數(shù)字,和空格,沒有顏色,大小或其它的格式標記。</p><p>

43、  自從PHP作為Web編程語言出現(xiàn)以來,它便趨向于在HTML中使用,這大大增加了要返回給瀏覽器的信息量。PHP不僅要返回信息給用戶,而且也需要正確的格式化這些信息。</p><p>  為了使信息和標簽?zāi)軌蚝唵位旌?,PHP代碼被直接嵌入在HTML頁面中。開篇的例子比較清楚的演示了這一概念;程序里大部分是常規(guī)的HTML代碼,但PHP也會插入一些適當?shù)男畔⒌巾撁嬷小?lt;/p><p>  嵌入

44、式編程,將使程序員的工作更為便捷;你可以在任何你想要插入代碼的地方插入PHP代碼,剩下的地方就寫常規(guī)的HTML代碼了。然而,別忘了用PHP標簽封裝你的PHP代碼,否則你的代碼將不能被解析,而是會被直接顯示在HTML頁面上。</p><p>  下面的程序演示了一個嵌入式編程的例子:</p><p><b>  <?php</b></p><p

45、>  /* File: hello_world.php – displays “Hello, World!” */</p><p><b>  ?></b></p><p><b>  <html></b></p><p>  <head><title>Hello, Worl

46、d!</title></head></p><p>  <body bgcolor=”white” text=”black”></p><p><b>  Hello,</b></p><p><b>  <?php</b></p><p>  // Sen

47、d “World!” to the visitor’s browser</p><p>  echo “World!”;</p><p><b>  ?></b></p><p><b>  </body></b></p><p><b>  </html>&

48、lt;/b></p><p>  當Web服務(wù)器訪問這個文件的時候,PHP解釋器將會從頭到尾的逐行執(zhí)行文件中的命令。因此, PHP標簽間處理的信息就隨著echo語句一起返回給瀏覽器了。Web瀏覽器接收到的內(nèi)容和如下代碼所示效果相同:</p><p><b>  <html></b></p><p>  <head>

49、<title>Hello, World!</title></head></p><p>  <body bgcolor=”white” text=”black”></p><p>  Hello, World!</p><p><b>  </body></b></p>

50、<p><b>  </html></b></p><p>  然后瀏覽器就可以像顯示其它HTML文件一樣顯示“Hello World!”信息了。</p><p><b>  服務(wù)端和客戶端腳本</b></p><p>  就像先前解釋的一樣,在信息返回瀏覽器之前,PHP代碼要在Web服務(wù)器端執(zhí)行,這

51、被稱為服務(wù)器端處理。大多數(shù)的Web編程都是以這種形式存在的:像ASP、PHP、Perl、C等。</p><p>  然而,還有一些語言是在瀏覽器接收到返回的頁面時進行處理的。這就是所謂的客戶端處理。最常見的例子就是JavaScript。</p><p>  這可能會導(dǎo)致邏輯上的一個有趣的問題。下面的示例演示了這種情況:</p><p>  <script la

52、nguage=”JavaScript”></p><p>  if (testCondition())</p><p><b>  {</b></p><p><b>  <?php</b></p><p>  echo “<b>The condition was true!

53、</b>”;</p><p><b>  ?></b></p><p><b>  } else {</b></p><p><b>  <?php</b></p><p>  echo “<b>The condition was not t

54、rue.</b>”;</p><p><b>  ?></b></p><p><b>  }</b></p><p><b>  </script></b></p><p>  多數(shù)情況下,這么寫代碼的程序員通常希望只有一個echo語句被執(zhí)行。然

55、而,這兩句都將執(zhí)行,頁面將停留在生成錯誤的JavaScript頁面(因為echo語句中的信息不是有效的JavaScript代碼)。如果你還不是很清楚,繼續(xù)看下面的例子;如下的代碼會讓你更加明確。這段代碼是從以前的代碼片段中摘錄下來的,注意JavaScript是原封不動的,但PHP代碼已經(jīng)被調(diào)用了。PHP完全忽略了JavaScript代碼:</p><p>  <script language=”JavaSc

56、ript”></p><p>  if (testCondition())</p><p><b>  {</b></p><p>  <b>The condition was true!</b></p><p><b>  } else {</b></p>

57、<p>  <b>The condition was not true.</b></p><p><b>  }</b></p><p><b>  </script></b></p><p>  正如你所看到的,這會導(dǎo)致JavaScript執(zhí)行時的錯誤。將PHP和Java

58、Script代碼混合使用要小心:可以這樣做,但是要注意,PHP將永遠無視JavaScript的存在。為了成功地將二者結(jié)合起來,用PHP輸出JavaScript代碼是非常必要的。</p><p>  下面的例子就是這么做的:</p><p>  <script language=”JavaScript”></p><p>  if (testConditi

59、on())</p><p><b>  {</b></p><p><b>  <?php</b></p><p>  echo “document.write(‘<b>The condition was true!</b>‘);”;</p><p><b>

60、  ?></b></p><p><b>  } else {</b></p><p><b>  <?php</b></p><p>  echo “document.write(‘<b>The condition was not true.</b>‘);”;</p&

61、gt;<p><b>  ?></b></p><p><b>  }</b></p><p><b>  </script></b></p><p><b>  運行你的程序</b></p><p>  按照本文開始介紹的

62、過程,嘗試運行這個程序。</p><p>  你將在你的瀏覽器里看到 “Hello World!“。</p><p><b>  Why PHP?</b></p><p>  PHP is an excellent choice for Web programming. It has many advantages over other lan

63、guages, including other Web-oriented languages. To get a very general understanding of how the common Web programming languages compare, let’s compare them.</p><p>  ASP is Microsoft’s Web programming enviro

64、nment. (It’s not a language itself because it allows the programmer to choose from a few actual languages, such as VBScript or JScript.) ASP is simple, but too simple for programs that use complex logic or algorithms.<

65、;/p><p>  Besides ASP’s over-simplicity, many companies find it hard to budget for the expense of Microsoft licenses. Without even considering hardware costs, a Microsoft server could cost thousands of dollars

66、in licensing, whereas a comparable Unix-based operating system running PHP could be free.</p><p>  Another language well known for its use on the Web is Sun Microsystems’ Java. Java is praised for being plat

67、form-independent (a program written in Java can be run on virtually any computer without having to make any modifications to the program).</p><p>  Although Java does have its advantages, it has serious down

68、sides in development time, development cost, and execution speed. Java development is time-consuming because projects in Java must follow strict rules (imposed by Java) that require extensive planning. In addition to hig

69、h development time, the cost is also high because Java developers are expensive to hire. The cost is therefore potentially much higher than it would be if the project were done in another language. Even after the project

70、 </p><p>  Overall, when compared to Java, PHP comes out with flying colors. It is not unheard of for a Java project to take two or three times the time to develop compared to a similar project in PHP. On to

71、p of that, the final program runs on a wide array of platforms (like Java), except the PHP program runs faster.</p><p>  Another language commonly used for writing Web programs is Perl. Perl, like PHP, is an

72、 open-source project developed to run on many platforms. In fact, Perl has been around longer than PHP. Before PHP, Perl was generally accepted as the best Web programming language. However, during the past few years, PH

73、P has earned a reputation for being better than Perl for Web programming because PHP provides a vast number of features as part of PHP itself, whereas you would have to download separate modules</p><p>  The

74、 last language to compare PHP to is C. C has been around for a long time; it has been used in a variety of computers, from mainframes to consumer PCs. The problems creating a Web program in C are obvious if you know C. T

75、o develop a Web program in C, you have to develop all of the basic functionality of Web programming (such as collecting the data from HTML forms) before you can even begin to think about the actual task at hand. Since PH

76、P provides for all the common (and many uncommon) Web pro</p><p>  You could write volumes on PHP’s advantages over other programming languages when it comes to Web programming. There are many, many articles

77、 on the Internet comparing PHP to Java, Perl, ASP, and others. Once you’ve earned some experience programming in PHP, you might find yourself trying to convince your client or employer to allow you to use it instead of a

78、nother language. If that problem arises, you should find plenty of helpful information by doing a Web search.</p><p>  PHP has an unlimited number of uses. The original version was used solely to track who w

79、as viewing the creator’s resume. Over time, however, that simple tracking program evolved into a language of its own.</p><p>  PHP’s primary use certainly isn’t to track resumes anymore; it has grown to be a

80、ble to do that and just about anything else. To give you a better idea of what PHP can do, here are some of its common uses:</p><p>  ? Feedback forms</p><p>  ? Shopping carts and other types o

81、f e-commerce systems</p><p>  ? User registration, access control, and management for online subscription services</p><p>  ? Guest books</p><p>  ? Discussion and message boards<

82、;/p><p>  If You Are New to Programming</p><p>  If you’ve never written a computer program before, the whole idea may be quite intimidating. Most programmers will probably tell you (if they aren’t

83、 embarrassed to admit it) that they were intimidated when they began. However, the programming process isn’t all that difficult and, contrary to popular belief, you don’t have to have an extremely high IQ to be good at i

84、t.</p><p>  When you write a program, your main goal is to translate your idea into a language that the computer can understand. For example, if you were teaching a person how to cook hamburgers, you would f

85、irst describe the process of forming the ground beef into patties. Then, you would tell the person how to put the burgers on the grill, how long to leave them there, and finally how to remove them.</p><p>  

86、Of course, just because you can describe the process of making hamburgers doesn’t mean PHP is going to be cooking anything for you anytime soon. The point is, if you can describe a process like I just described making ha

87、mburgers, you can write a program.</p><p>  Writing a PHP program is simply the process of describing to PHP how to do something. By the time you’ve finished reading this article, you will understand all the

88、 concepts behind writing a PHP program. Those concepts are like the words and sentences used to describe hamburgers. The more you read this article, the more “words” you will understand, and the better you will be able t

89、o “describe” your task to PHP. Thus, you will learn to write PHP programs to suit whatever need or idea you have, and</p><p>  Some programming problems might be very complex when examined as a whole. For ex

90、ample, creating a shopping cart is definitely not a simple task. However, a shopping cart can be broken into a few smaller tasks. Those tasks might include adding and removing items, which are both tasks that can break i

91、nto even smaller tasks. You will find that any task, no matter how complex, can be broken into smaller ones until each task is simple enough that breaking it down further is unnecessary. This process </p><p>

92、;  Writing a Basic PHP Program</p><p>  Before we get into an actual program, let’s take a look at the steps we’ll take to create one. The steps aren’t complicated; in fact, they’re basically the same as the

93、 steps you use when creating an HTML page and publishing it to your server.</p><p>  Unlike creating an HTML page, creating a PHP program requires that you actually work with the source code of the file as o

94、pposed to a “what you see is what you get” (WYSIWYG) approach. If you’re used to using a WYSIWYG program (such as Microsoft FrontPage, Macromedia Dream-Weaver, or Microsoft Word), it may take you some time to get used to

95、 looking at the source code.</p><p>  The good news is there’s no reason that you can’t continue to use a WYSIWYG editor to create an HTML design for your program. However, you may be disappointed to find th

96、at many WYSIWYG editors mangle or even delete vital PHP code from your files. For this reason, it is important to find out how your particular editor handles PHP code. If you want to test your WYSIWYG to see how it handl

97、es PHP code, create a new file, naming it with a .php extension. Then, switch to your editor’s source view or o</p><p>  When you’re finished, save the file and switch back to the WYSIWYG editor. If you see

98、your PHP code, work around it and type a few lines of text. If you want, add some common elements that you include in your Web pages, such as tables and images. Save the file again and close all the open editors.</p&g

99、t;<p>  Now, open the file in Notepad and look at the PHP code. Look for any changes, including changes in the way the code is formatted, special characters that have been converted into codes (such as < to &am

100、p;lt;), and code that has been completely removed.</p><p>  You will probably find that the PHP code has been changed in some way. Because PHP is sensitive to some of the changes a WYSIWYG editor might make,

101、 it’s almost impossible to use a WYSIWYG editor once you’ve started adding PHP code. The PHP community won’t tell you that using a WYSIWYG editor is a sign of weakness; doing so can speed things up a lot sometimes.</p

102、><p>  For now, try using a plain-text editor when you’re reading and experimenting with the examples in this article. When you’re comfortable with that, feel free to try it with whatever editor you want. By th

103、at time, you’ll be able to recognize code that the editor has mangled, and you’ll have an easier time finding what works best for you.</p><p>  Regardless of how your current editor handles PHP code, if you

104、are using a WYSIWYG editor, I suggest that you use an editor such as Notepad or one of the many free syntax-highlighting editors out there. Using one of these programs will ensure that your code stays just as you typed i

105、t (WYSIWYG editors tend to reformat things as they see fit, which isn’t desirable when coding PHP). Even if your editor passed the test, if it’s not a strictly text based (not WYSIWYG) editor, you might find yourself <

106、;/p><p>  Here is the process you might use in creating and viewing an HTML file:</p><p>  1. Create your HTML file (add text, tables, images, or sounds).</p><p>  2. Save your HTML fi

107、le as filename.html.</p><p>  3. Use an FTP program to upload your file to the Web server.</p><p>  4. Point your browser to the address of the file on your Web server (for example, http://www.e

108、xample.com/filename.html).</p><p>  The process you would use to create a PHP program is much the same:</p><p>  1. Create your HTML file (containing text, tables, images, or sounds) and insert

109、PHP code where desired.</p><p>  2. Save your PHP file as filename.php.</p><p>  3. Use an FTP program to upload your file to the Web server.</p><p>  4. Point your browser to the a

溫馨提示

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

評論

0/150

提交評論