(PDF) Ajax Trong Php – DOKUMEN.TIPS

Embed Size (px)

ApLediidctuk:W ytare Lrdler^ipTrung tm o to lp trnh vin quc t
AiTi-AptechTrnh by:Nguyn ThanhNam
edu.vnfa.l o. l sNi dung hi thovtan oi LeadershipGii thiu v PHP C
php trong PHP AJAXMusic website using PHP &
edu.vnfacebookVietnamCy WORL PTh%vut-mt ft 4t*igTRANG CHUCAULAC
EmailBanquenmatkhau?CHUYEN NHA TII365Facebook hel ps you connectand
share wi t h t he people in yourl if e.SignUpIt’s free and anyone
can join4ssj quatigtS!111ul l i eh .i l l l i l tSi l i l i VM1 l
> i l u i r I,CM-iS&ZJ fcr…… A’.Pi–…..A”%Tbcfl Stax
b”vng 1t W/5 (tn Z4h ngi vnglh sng ngy 14/4 Mn 2h ngia tea page for
a celebrity, band or business, click hiGet Y ahoo!Toolbar
withAnti-Spy’ X H o O fWebImagesVideoLocalShoppingmoreSeethelatest
environmentally friendlySearch:LWebSearchI mai npage| discussion| |
viewsource| | history|WelcometoWikipedia,the free encyclopedia that
anyone can edit.2,358,644 articles in EnglishOverview Editing
Questions HelpdiggJoi n Di ggAbout Logi nApr 28,2009I Page
OptifSports I VideoTechnologyvWorld &BusinessvSciencer
GamingvLifestylevEntertainment vSportsvOffbeat *ne f lu:5 t hi ngs
toknowworld may be on the brink of the first inza pandemic in more
than 403. Arewe ready for i t?itpandemics FlubasicsS tatisticsr T
v’ s taiHiid085 S g iMail( ^)M essengerPuz;-Weather83 FPop u l ar
Upcoming SETA News Videos Images CustomizeYah o o ! Sp o r t s s h
o pYour Source for Final Four gear1,000factoryNews, Images, Videos
I opIn24Hr 7Days30Days365DaysftQ iDiggDialogg with Sir Richard
Branson!IILSubmit your questions for our next Digg Dialogg with
Virgin Group founder Sir Richard Branson,presented by
Freecreditreport ciHow Swine FluSpreads from Pigs to Humansimage
growatrain.typepas.com(Pets&Animals: maflepopular
14mlnago5SComments Share Bury 4*I msaleemsubmittedRunning Windows
7RCon a netbookGA MEOFTlUFTINSTORE THliMU) W o k d P r e s s
.J8___Sr VWdPr&ss.canB”S:QCOMHome SignUpFeatures Blog Our
Story Advanceddiggs wo9s.computerwona.com How does
Microsoft’slatest Windows7 leak.Build 7100 run on a netbook,
theDell Mini 9 in specific? Here’sywhat I
found.More,..fMicrowHRdigg 22Comments Share Bury sjvnmadepopular
14minago 3558 U IThe Me214diggsdiggPrometheus Creating Saturn
RingStreamersIMAGE apod.nasa.gov(Space)
madepopular24mmago10Comments Share Bury louiebaursubmittedExpress
yourself. Start a blog.1Sign Up NowlSeeour freefeatures *1173,004
“9l4′-Viral Flu: EarthsOldest Trojan Horse-invaders
ANHORSE-INVADERSCultureof UfaNews2Virusesareoneof
wasone[…]CultureofLifeWws100} , vt’ars i Leadership PHP l g? M
hnh hot ng Lch s pht trin L do s dng Cc con sPHP l g ? PHP c pht
trin t ngn ng kch bn (script) vi mc ch xy dng trang Web c nhn
(Personal Home Page).Sau c pht trin thnh mt ngn ng hon chnh v c a
chung trn ton th gii trong vic pht trin cc ng dng Web based PHP
(PHP: Hypertext Perprocessor) l ngn ng kch bn lp trnh pha my ch
(server-side) ph bin nht th giiCOMPUTEREDUCATI ONwww. aiti-aptech.
edu.vnAPTECHTMyear* Leadership PHP thng hot ng theo th t sau:1.Ngi
dng gi yu cu ln my ch2.My ch x l yu cu (Thng dch m PHP v chy chng
trnh, m PHP c th truy xut CSDL, to hnh nh, c ghi file, tng tc vi my
ch khc…)3.My ch gi d liu v cho ngi dng (thng l di dng HTML)ApLeth
Lckbutcjirk M h n h \ \ c \ \ i nn’Da r tmw.CTaropkiDiTT, pteeenrt
me/ catoMmlYour desktop PCInternet4*’s t tip : //vwflxampli jMfli
/oatj k>g/yjk.phpWb Serverwwv/.exampl&cm Web ServerAplech^ L
ch s pht trinyean oi Leadership PHPc pht trin nm1994, bao gm cc
macro cho trang Web c nhn (Personal Home Page) bi Rasmus Lerdorf.
PHP 2 (1995) nng cp thm mt vi chc nng mi hon thin hn so vi phin bn
u tin. (H tr Database, file upload, array, conditionals, iteration,
regular expressions…)COMPUTEREDUCATI ONWWW. aiti-aptech.
edu.vnAPTECHTMApteih^ L ch s pht trinyean oi Leadership PHP 3
(1998) c pht trin vi b dch mi vi tc nhanh hn v khc phc nhng nhc im
trong phin bn trc y bi Zeev Suraski v Andi Gutmans. Phin bn ny cn h
tr thm ODBC v cc hm lm vic vi giao thc email (SMTP,IMAP ). PHP 4
(2000) Nng cp b dch hon thin hn vi vic h tr nhiu tnh nng bo mt
trong PHP. B dch c i tn thnh Zend Engine. PHP 5 (2004) c nng cp ln
Zend Engine II vi kh nng lpt^^rng i tng.APTECHCOMPUTEREDUCATI
ONWWW. aiti-aptech .eu.vnAplrdl t,ctebrJ t(* L ch s pht trinvtan oi
LcadcrshipTnh n thng 7 nm 2007 PHP c s dng trn 20,917,850 domain
vi1,224,183 IP address.PHPUsagefor J ul2007APTECHCOMPUTEREDUCATI
ONwww. aiti-aptech. eu.vnL do s dng1.D dng s dngCode php c nhng
ngay trong code HTML. PHP code s c nm trong mt cp th c bit iu ny
gip trnh x l d dng phn bit code php so vi code HTML.


echo “Hi, I’m a PHP script!”;

Short ASP Script tags cscriptlanguage=php>

* Nn dng kiu standardAPTECHCOMPUTEREDUCATI ONWWW. aiti-aptech.
edu.vnCu phap trong PHP.tan. udLeadershipChu thich trong PHP

This is a PHP program

11j,’iULI1UUIM.fl&Cu phap PHPMtarsid Leadership Ajax in
depth Nicholas Peter Mannng Pro PHP Paul c.Zakas FirstNew y ears
oLrjdrrvhip5. nh dng d liu XML XML l inh dang chun cho cc dich vu
Web o XML thc t chm hn khi truyn so vi Plain Text v JSON Cu trc
XMLd hiu nhng khng n gin xy dng Gp phi vn tng thch trnh duyt khi
parse vn bn XML Trong mi trng hp, xem xt s dng Plain Text,Cp
Attribute /Value hoc JSON,sau mi ti XMLveanoLeadershi p5. nh dng d
liu JSONJSON -Javascript Object Notion -JSON.org nh dng d liu
lightweight Gia trn c php JavaScript (Array v Object literals)JSON
cho php chuyn cc i tng Javascriptthnh cc chui c th gi cng http
request.JSON c h tr bi hu ht cc ngn ng, vi PHP : JSON.php thnh phn
th vin h tr encode/decode nh dng chui sang PHP Object v ngc liThn
thin vi Developer, n nh, c chp nhn rng riAPTECH5. Dinh dang dir
lieu JSONo var people ={“programmers”:[{“firstName”:”Brett”,
“lastName”:”Hunter},{“firstName”:”Elliotte”, “lastName”:”Harold
}],”authors”: [{“firstName”:”Isaac”, “lastName”:”Asimov”,”genre”:
“Sciencefiction” },{“firstName”:”Tad”, “lastName”:”Williams”,
“genre”: “fantasy”},{“firstName”:”Frank”, “lastName”:”Peretti”,
“genre”: “Christian fiction”}], “musicians”:[{“firstName”:”Eric”,
“lastName”:”Clapton”, “instrument”:
“guitar”},{“firstName”:”Sergei”, “lastName”:”Rachmaninoff”,
“instrument”: “piano”}]5. inh dang d liu JSONo Truy cp v thay i d
liupeopl e. pr ogr ammer s[ 0] . l ast Name;peopl e. pr ogr ammer
s[ 0] . l ast Name= “Boss”; Chuyn mng thnh stringj sonText = J SON.
st r i ngi f y( peopl e) ; Chuyn i tng thnh stringj sonText = J
SON. st r i ngi f y( aper son) ;year LeadershipDemo Ajax &
edu.vnwww.netvibes.comyears Leadership6.Ajax, Widget, v
WebservicesWeb 2.0 -Web l nn tng gm nhiu dch y (Web-services)M a p
s , Search, Desktop,Picasa, Sitemaps, Geo,OpenSocial
Adwords,Finance, Calendar, Authentication,Ajax Search, Ajax
Language, Ajax Feed, Visualization, 03D, Book, GoogleEarth, Blogger
Data, Google Basedel.icio.us, Finance, flickr, Hot Jobs, Maps,
Merchant Solutions,Music,Design Patterns, RSS Feeds, Search,
SearchMarketing, Shopping, Travel, Traffic,upcoming.org,Ul library,
weather,webjay,Widgets, JS Developer Center,PHP Developer CenterH x
n o o f , DEVELOPERNETWORKG pQ eCodeApLeth Lckbutcsi ‘ ivtfan. oi
LeadershipAjaxWidget, v Webservicesinbox >+ < day ?1<
dayfc>< Tveat her >Weather.com response co dinh dang XML
hoac JSONwww. aiti-aptechedu.vnA plrdl ccfcbfiilESvtan
oiLeadershipAjax6.Ajax, Widget, v WebservicesDemo Ajax & JSON
Web serviceMakeY!MyHomepageY a H o O Itr a v e lHomeResear cht r a
v elg u id e s BookDeal sMyTravel * ThemesSEARCH TRAVEL:FindIt
FastSearchhere for cheap airline tickets,hotels,carscruisesand
vacationsAVERTI SEMENTHotels Cars I VacationsI| Cruises Fl i
ghts(?)Flight Only0 Flight * Hotel Book together 5 Si
FROMHANQne-Wav. Multi-City. More…DEPART RETURN05/18/09B ;05/25/09
H jgyyilToday’sPicksforY ahoOOoo! cOolTravelingfr.orrr Hanoi,
Vietnam ICiiBrge Location | SHOWME My Recommendat i ons’Mi ami .FL
CaboSanLucas.Mexi coToday’s Deals$485 – Riu Ocho Riosall-incl4-nt
trip w/flight BeachDestinations.com $98US flight saleMajor Airlines
$87- Swank Conrad Miamiwithbay-view-Yahoo Travel Web Services (Ajax
& J SON)-Keywords :[japan SearchJ apan (Kansai)We landed at
KansaiInternational in the afternoon, and made our way to Kyoto by
the J R limited express train. Too late and too tired to explore
the temples,wewalkedfromKyotoStationtothehotelpassingHigashi
Honganjii. Thehotel,Ikoi-no-ieisasmallguesthouse I minkishu.with
spotlessrooms.J apandoesnthavedaylightsavingstime,sothe sunrise is
early. Consequently, we wokeup at 5am and walked down to Toji
templemarket. On the way we passedNishi Honganjiand walked under
therailroad tracks. The market was just opening as we got there.
The guidebooks we’d read advised us to …Yokoso! J apan!PROLOGUE I
ammaking this journal to hopefully’ inspire people tograb their bag
and travel around the world This was my first trip aloneoutside of
Canada,its a hastily planned trip so there werea lot of things that
Iveoverlooked like when to go, budget, memory cards, souvenirs – to
name a few. I hadno soliditerinary until I got to Matsumoto where I
decided to go Castle hunting.On largecities Istayed inBusiness
Hotels,on smaller ones in Ryokan (traditional inn)-with private
facilities as I wake up early tobeat thecrowds.Ihighly
recommendstayinginaryokan.Ihadno problem co…APTECHCOMPUTEREDUCATI
ONWWW. aiti-aptech. edu.vnvean o Lrjdrrvhip7. Ajax ToolkitsThit k v
xy dng cc ng dng Ajax vi Ajax Toolkits(Frameworks,
Libraries…)< 9yean. oi Leadership7. Ajax ToolkitsBindowsRich
internet Application DevelopmentFrameworkmoo roofsQuen/ wr i t
*less,do more.dojoASfinetAJAXO Ext JSprototypeYU
ILibraryDWRAPTECHCOMPUTEREDUCATI ONwww. aiti-aptech. edu.vnyears o
Leadership7. Ajax Toolkits u im ca cc th vin AjaxSng gi sn cc phng
thc/i tng STng thch trnh duyt (Cross-Browser)SGim chi ph pht trin
cc ng dng RIA SH tr cc hiu ng Javascript (animation, drag sThao tc
vi DOM d dng7. Ajax Toolkits Cn xem xt cc yu t kh chn la th vin
Ajax ‘S H tr Server-driven hay Client driven ‘S Giy php m – Open
Licensinghay $$$’S Ti liu h tr, demos ‘S Cng ng pht trin ‘S Mc
abstraction hay highlevel ‘S Ngn ng hng ti (C#, PHP, Python, Java)
‘S C kh nng pht trin khng.years oiLeadership7. Ajax
ToolkitsPrototype Library $(‘id_of_element’)->
document.getElementByld() $F() -> get Value of element
Object-oriented extensionsAPTECHCOMPUTEREDUCATI ONytare ui LrjiJ ef
ship7. Ajax ToolkitsX l Ajax Request/Response n ginf unct i oncr
eat eRequest ( ur l ) {var xhr = newAj ax. Request ( ur l , { met
hod: 1get 1 fonCompl et e:showResponse});}f unct i onshowResponse(
xhr ) {$( ‘ di v’ ) . i nner HTML= xhr . r esponseText ;}ytare ui
Lrji Jef ship7. Ajax ToolkitsX l Ajax Request/Response n ginf unct
i oncr eat eRequest ( ur l ) {var xhr = newAj ax. Request ( ur l ,
{ met hod: 1get 1 fonCompl et e:showResponse});}f unct i
onshowResponse( xhr ) {$( ‘ di v’ ) . i nner HTML= xhr . r
esponseText ;}ApLediLdctHjIc’.4 r *Event . obser ve( wi ndow, ‘ l
oad’ , i ni t , f al se) ;f unct i oni ni t ( ) {Event . obser ve(‘
bt nBut t on’,’ cl i ck’ , makeRequest , f al se) ;}f unct i
onmakeRequest(){var xhr = newAj ax.Request (” hel l op. php”, { met
hod: ‘ get ‘ , onCompl et e: showResponse,par amet er s: {name:
$F(‘ t xt Name’ )}});}f unct i onshowResponse( xhr ) {$( ‘ cont ent
‘ ) . i nner HTML= xhr . r esponseText ;}years oiLrjitkf ship7.
Ajax ToolkitsT ng update n dungnewAj ax. Updat er ( 1pr oduct s 1
,f / some_ur l ! ,{met hod: 1get 1,i nser t i on: I nser t i on.
Top}) ;newAjax. Per i odi cal Updat er ( 1pr oduct s 1,1/ some_ur l
1 ,{met hod: 1get 1,i nser t i on: I nser t i on. Top,f req u en cy
:If decay: 2});8. Vn v thch thc vi ng dng AjaxAjax Trng thi ng dng
Ajax thay i, nhng URL th khng Lch s trnh duyt, cc dng Navigation
(TAB, TREE) Cc bc trong mt tin trnh Ngi s dng Confused vi nt Undo
Ti u ha Engine tm kim kh Bookmark trang web vn mg xem hin
tiCOMPUTEREDUCATI ONwww. aiti-aptech. edu.vnAPTECHTM Sch Ajax Ajax
in Action (Manning) HeadFirst Ajax (HeadFirst) Ajax Patterns and
Best Practices (Apress) Lin kt Webwww.aiaxian.com
http://www.aiaxlessons.com/ http://aiax.phpmagazine.net/
http://aiaxworld.com/Lin kt Webhttp://developer.vahoo.com/
http://code.google.com/apis/aiax/ http://aiaxpatterns.org/
http://www.aiaxmatters.com/ Link mt s th vin ph
binhttp://prototypeis.orghttp://iauerv.com Ni dung hi
tho:http://aptechvn. wordpress.com/ytan odLadenhlp* J 1 r .>
________ A 1 1 ______ 1 1 78. Gii thu cc t nguyn tham kho_ wyears
oi LeadershipDemo Ajax with PrototypeAPTECHCOMPUTEREDUCATI ONwww.
aiti-aptech. edu.vnyean Leadership