什么是PRADO?
PRADO是在PHP5環(huán)境下的一個(gè)基于事件驅(qū)動(dòng)和基于組件的WEB應(yīng)用開(kāi)發(fā)框架。使用PRADO開(kāi)發(fā)WEB應(yīng)用,你主要需要做的工作就是使用已有 的組件(原文是"實(shí)例化已經(jīng)定義好的組件",熟悉面向?qū)ο缶幊痰拈_(kāi)發(fā)者可能比較容易理解這句話),設(shè)置組件的屬性,為控件組件的各種事件編寫(xiě)對(duì)應(yīng)的處理函 數(shù),然后把這些組織成一個(gè)個(gè)的頁(yè)面。(譯者注:個(gè)人傾向于將component翻譯為組件,control翻譯為控件,事實(shí)上大多數(shù)場(chǎng)合兩者沒(méi)有什么區(qū) 別,但是為了讀者能夠更加容易理解原文,本文一律按此規(guī)則翻譯。)這個(gè)過(guò)程和使用RAD開(kāi)發(fā)工具(比如Delphi或者Visual Basic)來(lái)開(kāi)發(fā)Windows應(yīng)用程序非常類(lèi)似。
下面用一個(gè)簡(jiǎn)單的例子來(lái)說(shuō)明PRADO框架的工作原理。假定我們現(xiàn)在要使用PRADO來(lái)開(kāi)發(fā)一個(gè)常見(jiàn)的登錄頁(yè)面。首先我們選擇PRADO中的2個(gè)TTextBox控件和1個(gè)TButton控件來(lái)分別對(duì)應(yīng)用戶名輸入,密碼輸入和提交按鈕。然后把對(duì)應(yīng)密碼輸入的TTextBox控件的TextMode屬性設(shè)置為"Password",并為T(mén)Button控件的OnClick事件指定一個(gè)處理函數(shù)login。最后把這些控件放到頁(yè)面模板的合適的位置上(后面會(huì)解釋什么是頁(yè)面模板,實(shí)際上它和一個(gè)html頁(yè)面很相似),一個(gè)功能完善的登錄頁(yè)面就實(shí)現(xiàn)了。控件會(huì)自己處理好如何顯示數(shù)據(jù),如何得到用戶輸入的數(shù)據(jù),如何響應(yīng)用戶的操作等這些事情。例如,TTextBox控件會(huì)顯示一個(gè)輸入框讓用戶輸入;用戶輸入的密碼會(huì)被顯示為*號(hào),而開(kāi)發(fā)者在代碼中可以通過(guò)讀取TTextBox控件的Text屬性來(lái)獲取用戶實(shí)際輸入的密碼;當(dāng)用戶點(diǎn)擊了提交按鈕的時(shí)候,login 函數(shù)將會(huì)被自動(dòng)調(diào)用。這和傳統(tǒng)的PHP編程處理方式很不一樣。使用傳統(tǒng)的PHP編程方式,開(kāi)發(fā)人員需要使用HTML標(biāo)簽來(lái)顯示用戶輸入框 和按鈕,同時(shí)需要自己解析POST數(shù)據(jù)來(lái)獲得用戶的輸入以及判斷按鈕是否被點(diǎn)擊了等等這些事情。
PRADO 基于組件的編程方式使代碼的重用極為方便。一些重復(fù)性的單調(diào)的工作比如表單輸入的驗(yàn)證,頁(yè)面狀態(tài)的管理等都可以使用PRADO已經(jīng)提供的組件來(lái)處理。開(kāi)發(fā) 者也可以通過(guò)繼承現(xiàn)有的組件或者組合現(xiàn)有的組件來(lái)開(kāi)發(fā)新的組件滿足要求。另外一些新的組件即將發(fā)布。
目前已經(jīng)有很多PHP的框架,Mojavi, WACT, PHP.MVC, Phrame等等。它們主要是建立一套松散的PHP代碼組織方式(比如 Model-view-controller)。其中一些更多的面向開(kāi)發(fā)一個(gè)內(nèi)容管理系統(tǒng),并提供了諸如用戶管理模塊等更多的功能。
和這些框架相比,PRADO更專注于建立一個(gè)代碼重用和事件驅(qū)動(dòng)的編程標(biāo)準(zhǔn)。如果你曾經(jīng)用Delphi或者Visual Basic等這些RAD開(kāi)發(fā)工具來(lái)開(kāi)發(fā)Windows程序的話,那么你會(huì)發(fā)現(xiàn)使用PRADO來(lái)開(kāi)發(fā)WEB應(yīng)用是非常類(lèi)似的,你可以很快就掌握PRADO來(lái) 進(jìn)行WEB應(yīng)用的開(kāi)發(fā)。大多數(shù)情況下,你要做的僅僅是設(shè)置組件的屬性和響應(yīng)組件的事件。更高層次的代碼重用,比如前面所說(shuō)的用戶管理模塊,可以基于 PRADO組件來(lái)實(shí)現(xiàn)。
PRADO的思想最先我是從Apache Tapestry項(xiàng)目想到的。在設(shè)計(jì)和實(shí)現(xiàn)的時(shí)候, Borland Delphi 和Microsoft ASP.NET的設(shè)計(jì)思想起到了很重要的作用 。實(shí)際上,使用過(guò)ASP.NET的人可以發(fā)現(xiàn)PRADO中有很多地方和它是相似的。
安裝
PRADO需要PHP5的環(huán)境,以及SimpleXML模塊(PHP5缺省安裝后的環(huán)境下已經(jīng)包括了這個(gè)模塊)。在Windows XP和RedHat Linux環(huán)境下,已經(jīng)在Apache和IIS Web服務(wù)器上都通過(guò)了測(cè)試。
PRADO框架使用一個(gè).zip文件發(fā)布。在Linux下可以使用unzip,在Windows下可以使用Winzip來(lái)解壓。
解壓完畢后,會(huì)在當(dāng)前目錄下創(chuàng)建一個(gè)目錄prado。這個(gè)目錄主要包括以下這些文件和目錄:
README.html 此項(xiàng)目的說(shuō)明文件<p></p><p>index.html 和README.html中的內(nèi)容是一樣的</p><p>COPYRIGHT 此項(xiàng)目的版權(quán)信息</p><p>HISTORY 版本升級(jí)信息</p><p>framework/ PRADO框架的核心代碼</p><p>examples/ PRADO的一些例子</p><p>docs/ PRADO的幫助文檔</p><p></p>
完成了解壓之后,把prado目錄的所有東西復(fù)制到Web服務(wù)器的根目錄下。(也可以把它復(fù)制到某一個(gè)子目錄下,甚至更深層次的目錄下,PRADO對(duì)此沒(méi)有限制。如果你將它復(fù)制到了某一個(gè)子目錄下,以下的URL地址需要做相應(yīng)的修改。)

Hot AI Tools

Undress AI Tool
Undress images for free

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

TosecurelyhandleauthenticationandauthorizationinPHP,followthesesteps:1.Alwayshashpasswordswithpassword_hash()andverifyusingpassword_verify(),usepreparedstatementstopreventSQLinjection,andstoreuserdatain$_SESSIONafterlogin.2.Implementrole-basedaccessc

To safely handle file uploads in PHP, the core is to verify file types, rename files, and restrict permissions. 1. Use finfo_file() to check the real MIME type, and only specific types such as image/jpeg are allowed; 2. Use uniqid() to generate random file names and store them in non-Web root directory; 3. Limit file size through php.ini and HTML forms, and set directory permissions to 0755; 4. Use ClamAV to scan malware to enhance security. These steps effectively prevent security vulnerabilities and ensure that the file upload process is safe and reliable.

In PHP, the main difference between == and == is the strictness of type checking. ==Type conversion will be performed before comparison, for example, 5=="5" returns true, and ===Request that the value and type are the same before true will be returned, for example, 5==="5" returns false. In usage scenarios, === is more secure and should be used first, and == is only used when type conversion is required.

The methods of using basic mathematical operations in PHP are as follows: 1. Addition signs support integers and floating-point numbers, and can also be used for variables. String numbers will be automatically converted but not recommended to dependencies; 2. Subtraction signs use - signs, variables are the same, and type conversion is also applicable; 3. Multiplication signs use * signs, which are suitable for numbers and similar strings; 4. Division uses / signs, which need to avoid dividing by zero, and note that the result may be floating-point numbers; 5. Taking the modulus signs can be used to judge odd and even numbers, and when processing negative numbers, the remainder signs are consistent with the dividend. The key to using these operators correctly is to ensure that the data types are clear and the boundary situation is handled well.

Yes, PHP can interact with NoSQL databases like MongoDB and Redis through specific extensions or libraries. First, use the MongoDBPHP driver (installed through PECL or Composer) to create client instances and operate databases and collections, supporting insertion, query, aggregation and other operations; second, use the Predis library or phpredis extension to connect to Redis, perform key-value settings and acquisitions, and recommend phpredis for high-performance scenarios, while Predis is convenient for rapid deployment; both are suitable for production environments and are well-documented.

TostaycurrentwithPHPdevelopmentsandbestpractices,followkeynewssourceslikePHP.netandPHPWeekly,engagewithcommunitiesonforumsandconferences,keeptoolingupdatedandgraduallyadoptnewfeatures,andreadorcontributetoopensourceprojects.First,followreliablesource

PHPbecamepopularforwebdevelopmentduetoitseaseoflearning,seamlessintegrationwithHTML,widespreadhostingsupport,andalargeecosystemincludingframeworkslikeLaravelandCMSplatformslikeWordPress.Itexcelsinhandlingformsubmissions,managingusersessions,interacti

TosettherighttimezoneinPHP,usedate_default_timezone_set()functionatthestartofyourscriptwithavalididentifiersuchas'America/New_York'.1.Usedate_default_timezone_set()beforeanydate/timefunctions.2.Alternatively,configurethephp.inifilebysettingdate.timez
