•
•
•
•
•
•
TableofContents
Index
Reviews
ReaderReviews
Errata
Academic
LearningPHP5
ByDavidSklar
Publisher :O'Reilly
PubDate :June2004
ISBN :0-596-00560-1
Pages :368
LearningPHP5istheidealtutorialforgraphic
designers,bloggers,andotherwebcrafters
whowantathoroughbutnon-intimidating
waytounderstandthecodethatmakesweb
sitesdynamic.Thebookbeginswithan
introductiontoPHP,thenmovestomore
advancedfeatures:languagebasics,arrays
andfunctions,webforms,connectingto
databases,andmuchmore.Completewith
exercisestomakesurethelessonsstick,this
bookofferstheidealclassroomlearning
experiencewhetheryou'reinaclassroomor
onyourown.
•
•
•
•
•
•
TableofContents
Index
Reviews
ReaderReviews
Errata
Academic
LearningPHP5
ByDavidSklar
Publisher :O'Reilly
PubDate :June2004
ISBN :0-596-00560-1
Pages :368
Copyright
Dedication
Preface
WhoThisBookIsFor
ContentsofThisBook
OtherResources
UsingCodeExamples
ConventionsUsedinThisBook
CommentsandQuestions
Acknowledgments
Chapter1.OrientationandFirstSteps
Section1.1.PHP'sPlaceintheWebWorld
Section1.2.What'sSoGreatAboutPHP?
Section1.3.PHPinAction
Section1.4.BasicRulesofPHPPrograms
Section1.5.ChapterSummary
Chapter2.WorkingwithTextandNumbers
Section2.1.Text
Section2.2.Numbers
Section2.4.ChapterSummary
Section2.3.Variables
Section2.5.Exercises
Chapter3.MakingDecisionsandRepeatingYourself
Section3.1.Understandingtrueandfalse
Section3.2.MakingDecisions
Section3.3.BuildingComplicatedDecisions
Section3.5.ChapterSummary
Section3.4.RepeatingYourself
Section3.6.Exercises
Chapter4.WorkingwithArrays
Section4.1.ArrayBasics
Section4.2.LoopingThroughArrays
Section4.3.ModifyingArrays
Section4.5.UsingMultidimensionalArrays
Section4.4.SortingArrays
Section4.6.ChapterSummary
Section4.7.Exercises
Chapter5.Functions
Section5.1.DeclaringandCallingFunctions
Section5.2.PassingArgumentstoFunctions
Section5.4.UnderstandingVariableScope
Section5.3.ReturningValuesfromFunctions
Section5.5.ChapterSummary
Section5.6.Exercises
Chapter6.MakingWebForms
Section6.1.UsefulServerVariables
Section6.2.AccessingFormParameters
Section6.4.ValidatingData
Section6.6.PuttingItAllTogether
Section6.8.Exercises
Section6.3.FormProcessingwithFunctions
Section6.5.DisplayingDefaultValues
Section6.7.ChapterSummary
Chapter7.StoringInformationwithDatabases
Section7.1.OrganizingDatainaDatabase
Section7.2.ConnectingtoaDatabaseProgram
Section7.4.PuttingDataintotheDatabase
Section7.6.GeneratingUniqueIDs
Section7.8.RetrievingDatafromtheDatabase
Section7.10.RetrievingFormDataSafely
Section7.12.MySQLWithoutPEARDB
Section7.3.CreatingaTable
Section7.5.InsertingFormDataSafely
Section7.7.ACompleteDataInsertionForm
Section7.9.ChangingtheFormatofRetrievedRows
Section7.11.ACompleteDataRetrievalForm
Section7.13.ChapterSummary
Section7.14.Exercises
Chapter8.RememberingUserswithCookiesandSessions
Section8.1.WorkingwithCookies
Section8.2.ActivatingSessions
Section8.4.ConfiguringSessions
Section8.6.Whysetcookie()andsession_start()WanttoBeattheTopofthe
Page
Section8.7.ChapterSummary
Section8.3.StoringandRetrievingInformation
Section8.5.LoginandUserIdentification
Section8.8.Exercises
Chapter9.HandlingDatesandTimes
Section9.1.DisplayingtheDateorTime
Section9.2.ParsingaDateorTime
Section9.3.DatesandTimesinForms
Section9.5.ChapterSummary
Section9.4.DisplayingaCalendar
Section9.6.Exercises
Chapter10.WorkingwithFiles
Section10.1.UnderstandingFilePermissions
Section10.2.ReadingandWritingEntireFiles
Section10.3.ReadingandWritingPartsofFiles
Section10.5.InspectingFilePermissions
Section10.4.WorkingwithCSVFiles
Section10.6.CheckingforErrors
Section10.7.SanitizingExternallySuppliedFilenames
Section10.8.ChapterSummary
Section10.9.Exercises
Chapter11.ParsingandGeneratingXML
Section11.1.ParsinganXMLDocument
Section11.2.GeneratinganXMLDocument
Section11.3.ChapterSummary
Section11.4.Exercises
Chapter12.Debugging
Section12.1.ControllingWhereErrorsAppear
Section12.2.FixingParseErrors
Section12.3.InspectingProgramData
Section12.5.ChapterSummary
Section12.4.FixingDatabaseErrors
Section12.6.Exercises
Chapter13.WhatElseCanYouDowithPHP?
Section13.1.Graphics
Section13.2.PDF
Section13.3.Shockwave/Flash
Section13.5.SendingandReceivingMail
Section13.7.TheHTML_QuickFormForm-HandlingFramework
Section13.9.AdvancedXMLProcessing
Section13.11.RunningShellCommands
Section13.13.Encryption
Section13.15.IMAP,POP3,andNNTP
Section13.17.PHP-GTK
Section13.4.Browser-SpecificCode
Section13.6.UploadingFilesinForms
Section13.8.ClassesandObjects
Section13.10.SQLite
Section13.12.AdvancedMath
Section13.14.TalkingtoOtherLanguages
Section13.16.Command-LinePHP
Section13.18.EvenMoreThingsYouCanDowithPHP
AppendixA.InstallingandConfiguringthePHPInterpreter
SectionA.1.UsingPHPwithaWeb-HostingProvider
SectionA.2.InstallingthePHPInterpreter
SectionA.3.InstallingPEAR
SectionA.4.DownloadingandInstallingPHP'sFriends
SectionA.5.ModifyingPHPConfigurationDirectives
SectionA.6.AppendixSummary
AppendixB.RegularExpressionBasics
SectionB.1.CharactersandMetacharacters
SectionB.2.Quantifiers
SectionB.4.CharacterClasses
SectionB.6.PHP'sPCREFunctions
SectionB.3.Anchors
SectionB.5.Greed
SectionB.7.AppendixSummary
SectionB.8.Exercises
AppendixC.AnswersToExercises
SectionC.1.Chapter2
SectionC.2.Chapter3
SectionC.4.Chapter5
SectionC.6.Chapter7
SectionC.8.Chapter9
SectionC.10.Chapter11
SectionC.3.Chapter4
SectionC.5.Chapter6
SectionC.7.Chapter8
SectionC.9.Chapter10
SectionC.11.Chapter12
SectionC.12.AppendixB
Colophon
Index
Copyright©2004O'ReillyMedia,Inc.
PrintedintheUnitedStatesofAmerica.
PublishedbyO'ReillyMedia,Inc.,1005GravensteinHighway
North,Sebastopol,CA95472.
O'Reillybooksmaybepurchasedforeducational,business,or
salespromotionaluse.Onlineeditionsarealsoavailablefor
mosttitles().Formoreinformation,
contactourcorporate/institutionalsalesdepartment:(800)
998-9938or
NutshellHandbook,theNutshellHandbooklogo,andthe
O'ReillylogoareregisteredtrademarksofO'ReillyMedia,Inc.
LearningPHP5,theimageofaneagle,andrelatedtradedress
aretrademarksofO'ReillyMedia,Inc.
Manyofthedesignationsusedbymanufacturersandsellersto
distinguishtheirproductsareclaimedastrademarks.Where
thosedesignationsappearinthisbook,andO'ReillyMedia,Inc.
wasawareofatrademarkclaim,thedesignationshavebeen
printedincapsorinitialcaps.
Whileeveryprecautionhasbeentakeninthepreparationofthis
book,thepublisherandauthorsassumenoresponsibilityfor
errorsoromissions,orfordamagesresultingfromtheuseof
theinformationcontainedherein.
Dedication
ToJacob,whocanlookforwardtosomuchlearning.
Preface
Boringwebsitesarestatic.Interestingwebsitesaredynamic.
Thatis,theircontentchanges.AgiantstaticHTMLpagelisting
thenames,pictures,descriptions,andpricesofall1,000
productsacompanyhasforsaleishardtouseandtakes
forevertoload.Adynamicwebproductcatalogthatletsyou
searchandfilterthoseproductssoyouseeonlythesixitems
thatmeetyourpriceandcategorycriteriaismoreuseful,faster,
andmuchmorelikelytocloseasale.
ThePHPprogramminglanguagemakesiteasytobuilddynamic
websites.Whateverinteractiveexcitementyouwantto
createsuchasaproductcatalog,ablog,aphotoalbum,oran
eventcalendarPHPisuptothetask.Andafterreadingthis
book,you'llbeuptothetaskofbuildingthatdynamicwebsite,
too.
WhoThisBookIsFor
Thisbookisfor:
Ahobbyistwhowantstocreateaninteractivewebsitefor
himself,hisfamily,oranonprofitorganization.
AwebsitebuilderwhowantstousethePHPsetupprovided
byanISPorhostingprovider.
Asmallbusinessownerwhowantstoputhercompanyon
theWeb.
Apagedesignerwhowantstocommunicatebetterwithher
developerco-workers.
AJavaScriptwhizwhowantstobuildserver-sideprograms
thatcomplementherclient-sidecode.
AbloggerorHTMLjockeywhowantstoeasilyadddynamic
featurestohersite.
APerl,ASP,orColdFusionprogrammerwhowantstogetup
tospeedwithPHP.
Anybodywhowantsastraightforward,jargon-free
introductiontooneofthemostpopularprogramming
languagesforbuildinganinteractivewebsite.
PHP'sgentlelearningcurveandapproachablesyntaxmakeitan
ideal"gateway"languageforthenontechnicalwebprofessional.
LearningPHP5isaimedatboththisinterested,intelligent,but
notnecessarilytechnicalindividualaswellasatprogrammers
familiarwithanotherlanguagewhowanttolearnPHP.
Asidefrombasiccomputerliteracy(knowinghowtotype,
movingfilesaround,surfingtheWeb),theonlyassumptionthat
thisbookmakesaboutyouisthatyou'reacquaintedwithHTML.
Youdon'tneedtobeanHTMLmaster,butyoushouldbe
comfortablewiththeHTMLtagsthatpopulateabasicwebpage
suchas<html>,<head>,<body>,
,<a>,and
.Ifyou're
notfamiliarwithHTML,readHTML&XHTML:TheDefinitive
Guide,FifthEdition,byBillKennedyandChuckMusciano
(O'Reilly).
ContentsofThisBook
Thisbookisdesignedsothatyoustartatthebeginningand
workthroughthechaptersinorder.Forthemostpart,each
chapterdependsonmaterialinthepreviouschapters.Chapter
2,throughChapter12andAppendixB,eachendwithexercises
thattestyourunderstandingofthecontentinthechapter.
Chapter1,providessomegeneralbackgroundonPHPandhow
itinteractswithyourwebbrowserandawebserver.Italso
showssomePHPprogramsandwhattheydotogiveyouan
ideaofwhatPHPprogramslooklike.Especiallyifyou'renewto
programmingorbuildingdynamicwebsites,itisimportantto
readChapter1.
Thenextfourchaptersgiveyouagroundinginthe
fundamentalsofPHP.Beforeyoucanwritegreatliterature,you
needtolearnalittlegrammarandsomevocabulary.That's
whatthesechaptersarefor.(Don'tworryyou'lllearnenough
PHPgrammarandvocabularyrightawaytostartwritingsome
shortprograms,ifnotgreatliterature.)Chapter2showsyou
howtoworkwithdifferentkindsofdatasuchaspiecesoftext
andnumbers.Thisisimportantbecausethewebpagesthat
yourPHPprogramsgeneratearejustbigpiecesoftext.Chapter
3,describesthePHPcommandswithwhichyourprogramscan
makedecisions.Thesedecisionsareattheheartofthe
"dynamic"in"dynamicwebsite."TheconceptsinChapter3are
whatyouuse,forexample,todisplayonlyitemsinaproduct
catalogthatfallbetweentwopricesauserentersinaweb
form.
Chapter4,introducesarrays,whicharecollectionsofabunch
ofindividualnumbersorpiecesoftext.Manyfrequentactivities
inPHPprograms,suchasprocessingsubmittedwebform
parametersorexamininginformationpulledoutofadatabase,
involveusingarrays.Asyouwritemorecomplicatedprograms,
you'llfindyourselfwantingtorepeatsimilartasks.Functions,
discussedinChapter5,helpyoureusepiecesofyourprograms.
Thethreechaptersafterthatcoverthreeessentialtasksin
buildingadynamicwebsite:dealingwithforms,databases,and
users.Chapter6,suppliesthedetailsonworkingwithweb
forms.Thesearetheprimarywaythatusersinteractwithyour
website.Chapter7,discussesdatabases.Adatabaseholdsthe
informationthatyourwebsitedisplays,suchasaproduct
catalogoreventcalendar.Thischaptershowsyouhowtomake
yourPHPprogramstalktoadatabase.Withthetechniquesin
Chapter8,yourwebsitecandouser-specificthingssuchas
displaysensitiveinformationtoauthorizedpeopleonlyortell
someonehowmanynewmessageboardpostshavebeen
createdsinceshelastloggedin.
Then,thenextthreechaptersexaminethreeotherareasyou're
likelytoencounterwhenbuildingyourwebsite.Chapter9,
highlightsthestepsyouneedtotake,forexample,todisplaya
monthlycalendarortoallowuserstoinputadateortimefrom
awebform.Chapter10,describesthePHPcommandsfor
interactingwithfilesonyourowncomputerorelsewhereonthe
Internet.Chapter11,suppliesthebasicsfordealingwithXML
documentsinyourPHPprograms,whetheryouneedto
generateoneforanotherprogramtoconsumeoryou'vebeen
providedwithonetouseinyourownprogram.
Chapter12andChapter13eachstandontheirown.Chapter
12,furnishessomeapproachesforunderstandingtheerror
messagesthatthePHPinterpretergeneratesandhuntingdown
problemsinyourprograms.Whileitpartiallydependsonearlier
material,itmaybeworthwhiletoskipaheadandperuse
Chapter12asyou'reworkingthroughthebook.
Chapter13servesatasteofmanyadditionalcapabilitiesofPHP,
suchasgeneratingimages,runningcodewritteninother
languages,andmakingFlashmovies.Afteryou'vegotten
comfortablewiththecorePHPconceptsexplainedinChapter1
throughChapter12,visitChapter13forlotsofnewthingsto
learn.
Thethreeappendixesprovidesupplementarymaterial.Torun
PHPprograms,youneedtohaveacopyofthePHPinterpreter
installedonyourcomputer(orhaveanaccountwithawebhostingproviderthatsupportsPHP).AppendixA,helpsyouget
upandrunning,whetheryouareusingWindows,OSX,or
Linux.
Manytext-processingtasksinPHP,suchasvalidatingsubmitted
formparametersorparsinganHTMLdocument,aremade
easierbyusingregularexpressions,apowerfulbutinitially
inscrutablepatternmatchingsyntax.AppendixB,explainsthe
basicsofregularexpressionssothatyoucanusetheminyour
programsifyouchoose.
Last,AppendixC,containstheanswerstoalltheexercisesin
thebook.Nopeekinguntilyoutrytheexercises!
OtherResources
TheonlineannotatedPHPManual( />isagreatresourceforexploringPHP'sextensivefunction
library.Plentyofuser-contributedcommentsofferhelpfuladvice
andsamplecode,too.Additionally,therearemanyPHPmailing
listscoveringinstallation,programming,extendingPHP,and
variousothertopics.Youcanlearnaboutandsubscribetothese
mailinglistsatAreadonlywebinterfacetothemailinglistsisat.
AlsoworthexploringisthePHPPresentationSystemarchiveat
.Thisisacollectionofpresentationsabout
PHPthathavebeendeliveredatvariousconferences.
Afteryou'recomfortablewiththematerialinthisbook,the
followingbooksaboutPHParegoodnextsteps:
ProgrammingPHP,byRasmusLerdorfandKevinTatroe
(O'Reilly).Amoredetailedandtechnicallookathowto
writePHPprograms.Includesinformationongenerating
graphicsandPDFs.
PHPCookbook,byDavidSklarandAdamTrachtenberg
(O'Reilly).AcomprehensivecollectionofcommonPHP
programmingproblemsandtheirsolutions.
EssentialPHPTools,byDavidSklar(Apress).Examplesand
explanationsaboutmanypopularPHPadd-onlibrariesand
modulesincludingHTML_QuickForm,SOAP,andtheSmarty
templatingsystem.
UpgradingtoPHP5,byAdamTrachtenberg(O'Reilly).A
comprehensivelookatthenewfeaturesofPHP5,including
coverageoffeaturesforXMLhandlingandobject-oriented
programming.
Thesebooksarehelpfulforlearningaboutdatabases,SQL,and
MySQL:
WebDatabaseApplicationswithPHP&MySQL,byDavid
LaneandHughE.Williams(O'Reilly).HowtomakePHPand
MySQLsinginharmonytomakearobustdynamicwebsite.
SQLinaNutshell,byKevinE.Kline(O'Reilly).The
essentialsyouneedtoknowtowriteSQLqueries.Covers
theSQLdialectsusedbyMicrosoftSQLServer,MySQL,
Oracle,andPostgreSQL.
MySQLCookbook,byPaulDuBois(O'Reilly).A
comprehensivecollectionofcommonMySQLtasks.
MySQLReferenceManual
(Theultimatesourcefor
informationaboutMySQL'sfeaturesandSQLdialect.
ThesebooksarehelpfulforlearningaboutHTMLandHTTP:
HTML&XHTML:TheDefinitiveGuide,byBillKennedyand
ChuckMusciano(O'Reilly).Ifyou'vegotaquestionabout
HTML,thisbookanswersit.
DynamicHTML:TheDefinitiveReference,byDanny
Goodman(O'Reilly).Fullofusefulinformationyouneedif
you'reusingJavaScriptorDynamicHTMLaspartoftheweb
pagesyourPHPprogramsoutput.
HTTPDeveloper'sHandbook,byChrisShiflett(Sams
Publishing).Withthisbook,you'llbetterunderstandhow
yourwebbrowserandawebservercommunicatewitheach
other.
Thesebooksarehelpfulforlearningaboutsecurityand
cryptography:
WebSecurity,Privacy&Commerce,bySimsonGarfinkel
(O'Reilly).Areadableandcompleteoverviewofthevarious
aspectsofweb-relatedsecurityandprivacy.
PracticalUnix&InternetSecurity,bySimsonGarfinkel,
AlanSchwartz,andGeneSpafford(O'Reilly).Aclassic
explorationofallfacetsofcomputersecurity.
AppliedCryptography,byBruceSchneier(JohnWiley&
Sons).Thenittygrittyonhowdifferentcryptographic
algorithmsworkandwhy.
Thesebooksarehelpfulforlearningaboutsupplementarytopics
thatthisbooktouchesonlikeXMLprocessingandregular
expressions:
LearningXML,byErikT.Ray(O'Reilly).Wheretogofor
morein-depthinformationonXMLthanChapter11.
LearningXSLT,byMichaelFitzgerald(O'Reilly).Yourguide
toXMLstylesheetsandXSLtransformations.
MasteringRegularExpressions,byJeffreyE.F.Friedl
(O'Reilly).Afteryou'vedigestedAppendixB,turntothis
bookforeverythingyoueverwantedtoknowaboutregular
expressions.
ConventionsUsedinThisBook
Thefollowingprogrammingandtypesettingconventionsare
usedinthisbook.
ProgrammingConventions
ThecodeexamplesinthisbookaredesignedtoworkwithPHP
5.0.0.TheyweretestedwithPHP5.0.0RC2,whichwasthe
mostup-to-dateversionofPHP5availableatthetimeof
publication.AlmostallofthecodeinthebookworkswithPHP
4.3aswell.ThePHP5-specificfeaturesdiscussedinthebook
areasfollows:
Chapter7:themysqlifunctions
Chapter10:thefile_put_contents()function
Chapter11:theSimpleXMLmodule
Chapter12:theE_STRICTerror-reportinglevel
Chapter13:somenewfeaturesrelatedtoclassesand
objects,theadvancedXMLprocessingfunctions,the
bundledSQLitedatabase,andthePerlextension
TypographicalConventions
Thefollowingtypographicalconventionsareusedinthisbook:
Italic
Indicatesnewterms,exampleURLs,exampleemail
addresses,filenames,fileextensions,pathnames,and
directories.
Constantwidth
Indicatescommands,options,switches,variables,
attributes,keys,functions,types,classes,namespaces,
methods,modules,properties,parameters,values,objects,
events,eventhandlers,XMLtags,HTMLtags,macros,the
contentsoffiles,ortheoutputfromcommands.
Constantwidthitalic
Showstextthatshouldbereplacedwithuser-supplied
values.
Thisiconsignifiesatip,suggestion,orgeneralnote.
Thisiconindicatesawarningorcaution.
UsingCodeExamples
Typingsomeoftheexampleprogramsinthebookyourselfis
instructivewhenyouaregettingstarted.However,ifyour
fingersgetweary,youcandownloadallofthecodeexamples
from />Thisbookisheretohelpyougetyourjobdone.Ingeneral,you
mayusethecodeinthisbookinyourprogramsand
documentation.Youdonotneedtocontactthepublisherfor
permissionunlessyou'rereproducingasignificantportionofthe
code.Forexample,writingaprogramthatusesseveralchunks
ofcodefromthisbookdoesnotrequirepermission.Sellingor
distributingaCD-ROMofexamplesfromO'Reillybooksdoes
requirepermission.Answeringaquestionbycitingthisbook
andquotingexamplecodedoesnotrequirepermission.
Incorporatingasignificantamountofexamplecodefromthis
bookintoyourproduct'sdocumentationdoesrequire
permission.
Weappreciate,butdonotrequire,attribution.Anattribution
usuallyincludesthetitle,author,publisher,andISBN.For
example:"LearningPHP5byDavidSklarCopyright2004
O'ReillyMedia,Inc.,0-596-00560-1."Ifyoufeelyouruseof
codeexamplesfallsoutsidefairuseorthepermissiongiven
above,feelfreetocontactthepublisherat
CommentsandQuestions
Pleaseaddresscommentsandquestionsconcerningthisbookto
thepublisher:
O'ReillyMedia,Inc.
1005GravensteinHighway
NorthSebastopol,CA95472
(800)998-9938(intheUnitedStatesorCanada)
(707)829-0515(internationalorlocal)
(707)829-0104(fax)
Thereisawebpageforthisbook,wherewelisterrata,
examples,andanyadditionalinformation.Youcanaccessthis
pageat:
/>Tocommentorasktechnicalquestionsaboutthisbook,send
emailto:
Oryoucancontacttheauthordirectlyviahiswebsite:
Formoreinformationaboutourbooks,conferences,Resource
Centers,andtheO'ReillyNetwork,seeourwebsiteat:
Acknowledgments
Thisbookistheendresultofthehardworkofmanypeople.
Thankyouto:
Themanyprogrammers,testers,documentationwriters,
bugfixers,andotherfolkswhosetime,talent,anddevotion
havemadePHPthefirst-classdevelopmentplatformthatit
istoday.Withoutthem,I'dhavenothingtowriteabout.
TheAppleWWPMHardwarePlacementLabfortheloanof
aniBook,andtoAdamTrachtenberg,GeorgeSchlossnagle,
andJeremyZawodnyforadviceonsomecodeexamples.
Mydiligentreviewers:GriffinCherry,FlorenceLeroy,Mark
Oglia,andStewartUgelow.Theycaughtplentyofmistakes,
turnedconfusingexplanationsintoclearones,and
otherwisemadethisbookfarbetterthanitwouldhave
beenwithoutthem.
RobertRomano,whoturnedmyblockydiagramsandrustic
pencilsketchesintohigh-qualityfiguresandillustrations.
TatianaDiaz,whofunneledallofmyrandomquestionsto
therightpeople,keptmeonschedule,andultimatelymade
surethatwhateverneededtogetdone,wasdone.
NatTorkington,whoseeditorialguidanceandhelpful
suggestionsimprovedeverypartofthebook.WithoutNat's
feedback,thisbookwouldbetwiceaslongandhalfas
readableasitis.
Forabetterfatethanwisdom,thankyoualsotoSusannah,
withwhomIenjoyignoringthesyntaxofthings.
Chapter1.OrientationandFirstSteps
Therearelotsofgreatreasonstowritecomputerprogramsin
PHP.MaybeyouwanttolearnPHPbecauseyouneedtoput
togetherasmallwebsiteforyourselfthathassomeinteractive
elements.PerhapsPHPisbeingusedwhereyouworkandyou
havetogetuptospeed.Thischapterprovidescontextforhow
PHPfitsintothepuzzleofwebsiteconstruction:whatitcando
andwhyit'ssogoodatwhatitdoes.You'llalsogetyourfirst
lookatthePHPlanguageandseeitinaction.