关闭

关闭

封号提示

内容

首页 Learning PHP and MySQL (O'Reilly 2007.2ed).pdf

Learning PHP and MySQL (O'Reilly 2007.2ed).pdf

Learning PHP and MySQL (O'Reill…

上传者: riemanncheng 2010-09-18 评分 0 0 0 0 0 0 暂无简介 简介 举报

简介:本文档为《Learning PHP and MySQL (O'Reilly 2007.2ed)pdf》,可适用于IT/计算机领域,主题内容包含LearningPHPandMySQLOtherresourcesfromO’ReillyRelatedtitlesEssentialPHPSecu符等。

LearningPHPandMySQLOtherresourcesfromO’ReillyRelatedtitlesEssentialPHPSecurityLearningPHPLearningMySQLMasteringRegularExpressionsMySQLCookbookMySQLinaNutshellMySQLPocketReferencePHPCookbookPHPHacksProgrammingPHPWebDatabaseApplicationswithPHPandMySQLoreillycomoreillycomismorethanacompletecatalogofO’ReillybooksYou’llalsofindlinkstonews,events,articles,weblogs,samplechapters,andcodeexamplesoreillynetcomistheessentialportalfordevelopersinterestedinopenandemergingtechnologies,includingnewplatforms,programminglanguages,andoperatingsystemsConferencesO’ReillybringsdiverseinnovatorstogethertonurturetheideasthatsparkrevolutionaryindustriesWespecializeindocumentingthelatesttoolsandsystems,translatingtheinnovator’sknowledgeintousefulskillsforthoseinthetrenchesVisitconferencesoreillycomforourupcomingeventsSafariBookshelf(safarioreillycom)isthepremieronlinereferencelibraryforprogrammersandITprofessionalsConductsearchesacrossmorethan,booksSubscriberscanzeroinonanswerstotimecriticalquestionsinamatterofsecondsReadthebooksonyourBookshelffromcovertocoverorsimplyfliptothepageyouneedTryittodayforfreeLearningPHPandMySQLSECONDEDITIONMicheleEDavisandJonAPhillipsBeijing•Cambridge•Farnham•Köln•Paris•Sebastopol•Taipei•TokyoLearningPHPandMySQL,SecondEditionbyMicheleEDavisandJonAPhillipsCopyright,MicheleEDavisandJonAPhillipsAllrightsreservedPrintedintheUnitedStatesofAmericaPublishedbyO’ReillyMedia,Inc,GravensteinHighwayNorth,Sebastopol,CAO’Reillybooksmaybepurchasedforeducational,business,orsalespromotionaluseOnlineeditionsarealsoavailableformosttitles(safarioreillycom)Formoreinformation,contactourcorporateinstitutionalsalesdepartment:()orcorporateoreillycomEditor:SimonStLaurentProductionEditor:MarloweShaefferCopyeditor:RebaLibbyProofreader:SohailaAbdulaliIndexer:EllenTroutmanZaigCoverDesigner:KarenMontgomeryInteriorDesigner:DavidFutatoIllustrator:JessamynReadPrintingHistory:June:FirstEditionAugust:SecondEditionNutshellHandbook,theNutshellHandbooklogo,andtheO’ReillylogoareregisteredtrademarksofO’ReillyMedia,IncLearningPHPandMySQL,theimageofkookaburrabirds,andrelatedtradedressaretrademarksofO’ReillyMedia,IncManyofthedesignationsusedbymanufacturersandsellerstodistinguishtheirproductsareclaimedastrademarksWherethosedesignationsappearinthisbook,andO’ReillyMedia,Incwasawareofatrademarkclaim,thedesignationshavebeenprintedincapsorinitialcapsWhileeveryprecautionhasbeentakeninthepreparationofthisbook,thepublisherandauthorsassumenoresponsibilityforerrorsoromissions,orfordamagesresultingfromtheuseoftheinformationcontainedhereinThisbookusesRepKover,adurableandflexiblelayflatbindingISBN:ISBN:MvTableofContentsPrefaceixDynamicContentandtheWebHTTPandtheInternetPHPandMySQL’sPlaceinWebDevelopmentTheComponentsofaPHPApplicationIntegratingManySourcesofInformationRequestingDatafromaWebPageInstallationDevelopingLocallyWorkingRemotelyExploringPHPPHPandHTMLTextCodingBuildingBlocksPHPDecisionMakingExpressionsOperatorConceptsConditionalsLoopingFunctionsCallingFunctionsDefiningFunctionsObjectOrientedProgrammingvi|TableofContentsArraysArrayFundamentalsWorkingwithMySQLMySQLDatabaseManagingtheDatabaseUsingphpMyAdminDatabaseConceptsStructuredQueryLanguageDatabaseBestPracticesDatabaseDesignBackingUpandRestoringDataAdvancedSQLGettingPHPtoTalktoMySQLTheProcessQueryingtheDatabasewithPHPFunctionsUsingPEARWorkingwithFormsBuildingaFormTemplatesPracticalPHPStringFunctionsDateandTimeFunctionsFileManipulationCallingSystemCallsXHTMLWhyXHTMLXHTMLandXMLNamespacesXHTMLVersionsGeneratingXHTMLwithPHPModifyingMySQLObjectsandPHPDataChangingDatabaseObjectsfromPHPManipulatingTableDataDisplayingResultswithEmbeddedLinksTableofContents|viiPresentingaFormtoAddandProcessinOneFileUpdatingDataDeletingDataPerformingaSubqueryCookies,Sessions,andAccessControlCookiesPHPandHTTPAuthenticationSessionsUsingAuthHTTPtoAuthenticateSecuritySessionSecurityValidationandErrorHandlingValidatingUserInputwithJavaScriptPatternMatchingRedisplayingaFormAfterPHPValidationFailsSampleApplicationConfigurationFilePageFrameworkDatabaseDisplayingaPostingsSummaryDisplayingaPostingandItsCommentsAddingandChangingPostsAddingandChangingCommentsFinishingYourJourneyPHPCodingStandardsPEARFrameworksAjaxWikisFindingHelpontheWebAppendixSolutionstoChapterQuestionsIndexixPrefacePHPandMySQLareapowerfulcombinationthatmakesiteasytocreatewebapplicationsIfyou’vebeencreatingwebpagesbutwanttobuildmoresophisticatedsitesthatcangrowandinteractwithusers,PHPandMySQLletyougetstartedeasilyandthenbuildcomplexapplicationsonthosefoundationsOurgoalistohelpyoulearntheinsandoutsofPHPandMySQLandtosaveyousomeofthe“Whydoesn’tthatwork”momentsthatwe’vealreadybeenthroughWe’llshowyouwhattowatchforandhowtofixtheseissueswithoutpullingoutyourhairAudienceThisbookisforpeoplewhowanttoknowhowtocreatedynamicwebsitesThatcouldincludegraphicdesignerswhoarealreadyworkinginanIToradvertisingfirmcreatingstaticwebsites,andwhomayneedtomoveforwardwithcodingdatabasedrivenwebsitesItmightalsoincludepeoplewhoalreadyknow,say,FlashdevelopmentandHTMLmarkup,butneedtoexpandtheirrepertoireofskillstodatabasesandprogrammingAssumptionsThisBookMakesThisbookassumesyouunderstandhowwebbrowsersworkandhaveabasicunderstandingofHTMLSomeunderstandingofJavaScriptmaybeuseful(forChapter)butisn’tgenerallyrequiredYoumightalsobeoverqualifiedIfyoualreadyknowhowtocreatepagesusingMySQLandPHP,thenyou’dprobablybebetteroffwithabookthatismoreareferencethanalearningbook,suchasPaulHudson’sPHPinaNutshell,orRussellDyer’sMySQLinaNutshell,bothfromO’Reillyx|PrefaceOrganizationofThisBookThisbookstartsoutwithanoverviewofhowallofthepiecesyou’llbeworkingwithfittogetherBecausetherearemultiplelanguagesandtechnologiesthatinteracttoformdynamicwebpages,it’sbesttostartwithasolidunderstandingofhowthepiecesworktogetherThePHPthatyou’lllearnworksasanintegrationpackagefordynamicwebsitesNext,we’llwalkthroughinstallingthecoresoftwarepackagesonyourlocalcomputerThisbookfocusesonPHPandMySQL,butmakingthisworkalsousuallyrequirestheApachewebserverThePHPinterpreterworkswiththewebserverwhenprocessingdynamiccontentFinally,you’llinstalltheMySQLdatabaseInstallationiscoveredforPC,Mac,andLinuxsystemsYoucanalsouseahostedInternetserviceprovider(ISP)accounttodevelopyourpages,ifyoudon’twanttoinstalleverythinglocallySincePHPplaysanimportantroleinpullingeverythingtogether,wenextexplainthebasicsofworkingwiththePHPlanguageThisincludeslanguageessentialssuchasdatatypes,programflowlogic,andvariablesFunctions,arrays,andformseachgettheirownchaptertofullyexplorethemBecauseyoumaybenewtodatabasesingeneral,weeaseintoMySQLbyfirstexplainingconceptsthatapplytodesigningandusinganyrelationaldatabaseThenwegivespecificexamplesofusingMySQLtointeractwithyourdataOnceyoucangetdatainandoutofthedatabase,you’llneedtoworkwithPHPtointegratethatdataintoyourdynamiccontentSecurityandaccesscontrolgettheirownchaptersWhilesecuritymaysoundlikeadullsubject,it’sstillahugeissueifyoustoreanyprivateinformationonyourwebpageWe’llguideyouaroundseveralcommonsecuritypitfallsWealsotouchonhowXHTML,thenextgenerationofHTML,workswithPHPandyourwebsitesFinally,weclosewithsampleapplicationsthatdemonstratehowthetechnologiesworktogethertorapidlybuildworkable,fastwebsitesYou’llalsobeprovidedwithwebsitesandforumstogainadditionalinformationonthetopicscoveredinthebookSupportingBooksEvenifyoufeelyouarereadyforthisbook,youmaywanttoexploresomeofthetechnologiesingreaterdepththanispossiblehereThefollowinglistofferssomegoodplacestostart:•RunYourOwnWebServerUsingLinuxApache,byTonySteidlerDennison(SitePoint)•PHPinaNutshell,FirstEdition,byPaulHudson(O’Reilly)Preface|xi•MySQLinaNutshell,FirstEdition,byRussellDyer(O’Reilly)•CSSCookbook,SecondEdition,byChristopherSchmitt(O’Reilly)Therearealsoseveralgoodonlineresourcesfordynamicwebdevelopment,includinghttp:onlampcom,partoftheO’ReillyNetworkLAMPstandsforLinux,Apache,MySQL,PHPLAMPisthedefactostandardforservingdynamicwebpagesConventionsUsedinThisBookThefollowingfontconventionsareusedinthisbook:ItalicIndicatespathnames,filenames,andprogramnamesInternetaddresses,suchasdomainnamesandURLsandnewitemswheretheyaredefinedConstantwidthIndicatescommandlinesnamesandkeywordsinprograms,includingmethodnames,variablenames,andclassnamesHTMLelementtagsvaluesanddatabaseenginesConstantwidthitalicIndicatestextthatshouldbereplacedwithusersuppliedvaluesConstantwidthboldIndicatesemphasisinprogramcodelinesanduserinputoptionsthatshouldbetypedverbatimThisiconsignifiesatip,suggestion,orgeneralnoteThisiconindicatesawarningorcautionUsingCodeExamplesThisbookisheretohelpyougetyourjobdoneIngeneral,youcanusethecodeinthisbookinyourprogramsanddocumentationYoudonotneedtocontactO’Reillyforpermissionunlessyou’rereproducingasignificantportionofthecodeForexample,writingaprogramthatusesseveralchunksofcodefromthisbookdoesnotrequirepermissionSellingordistributingaCDROMofexamplesfromO’ReillybooksdoesrequirepermissionAnsweringaquestionbycitingthisbookandquotingexamplecodedoesnotrequirepermissionIncorporatingasignificantamountofexamplecodefromthisbookintoyourproduct’sdocumentationdoesrequirepermissionxii|PrefaceWeappreciate,butdonotrequire,attributionAnattributionusuallyincludesthetitle,author,publisher,andISBNForexample:“LearningPHPandMySQL,SecondEdition,byMicheleEDavisandJonAPhillipsCopyrightMicheleEDavisandJonAPhillips,”Ifyoufeelyouruseofcodeexamplesfallsoutsidefairuseorthepermissiongivenabove,feelfreetocontactthepublisheratpermissionsoreillycomHowtoContactUsWehavetestedandverifiedtheinformationinthisbooktothebestofourability,butmistakesandoversightsdooccurPleaseletusknowaboutanyerrorsyoufind,aswellasyoursuggestionsforfutureeditions,bywritingto:O’ReillyMedia,IncGravensteinHighwayNorthSebastopol,CA(intheUnitedStatesorCanada)(internationalorlocal)(fax)Wehaveawebpageforthisbook,wherewelisterrata,examples,andanyadditionalinformationYoucanaccessthispageat:http:wwworeillycomcatalogThereisalsoablogforthisbooklocatedat:http:wwwkrautgrrlcomlearningphpTocommentorasktechnicalquestionsaboutthisbook,sendemailto:bookquestionsoreillycomFormoreinformationaboutourbooks,conferences,ResourceCenters,andtheO’ReillyNetwork,seeourwebsiteat:http:wwworeillycomSafariBooksOnlineWhenyouseeaSafariBooksOnlineicononthecoverofyourfavoritetechnologybook,thatmeansthebookisavailableonlinethroughtheO’ReillyNetworkSafariBookshelfSafarioffersasolutionthat’sbetterthanebooksIt’savirtuallibrarythatletsyoueasilysearchthousandsoftoptechbooks,cutandpastecodesamples,downloadchapters,andfindquickanswerswhenyouneedthemostaccurate,currentinformationTryitforfreeathttp:safarioreillycomPreface|xiiiAcknowledgmentsWearehappytohavethisnewlyimprovedandexpandedSecondEditionoutforouraudienceWe’dliketothankourwonderfulagent,MattWagnerofFreshBooks,alongwithSimonStLaurentatO’ReillyforgettingthisSecondEditionrollingwithoutthem,thisbookwouldn’tbeinyourhandsSecond,profusethankstoourtechnicaleditors,especiallyJeremeAllen,CharlieMaguire,andPeterMacIntyrefortheirfantasticeditstoourbookWe’dalsoliketothankourlocalMinneapolisStPaulPHPcommunity:http:wwwtcphporg,whichsparkedourinterestinPHPandMySQLyearsagoLastly,thankstoSimon,Mimi,andZackforbeingpatientwhiletheirparentsreworkedaveryimportantbookChapterCHAPTERDynamicContentandtheWebTotheaverageuser,awebpageisawebpageItopensinthebrowserandprovidesinformationLookingcloser,though,somepagesstaymostlythesame,whileotherpageschangeregularlyPagesthatdon’tchangestaticpagesarerelativelysimpletocreateSomeonehastocreateanHTMLdocument,byhandorwithtools,anduploadittoasitewherewebbrowserscanvisitOneofthemostcommontoolstocreateHTMLdocumentsisAdobeDreamweaverWhenchangesareneeded,youjustreplacetheoldfilewithanewoneDynamicpagesarealsobuiltwithHTML,butinsteadofasimplebuildandpostapproach,thepagesareupdatedregularly,sometimeseverytimethattheyarerequestedStaticsitesprovidehyperlinkedtextandperhapsaloginscreen,butbeyondthat,theydon’toffermuchinteractionBycontrast,Amazoncom(http:wwwamazoncom)demonstratesmuchofwhatadynamicwebsitecando:yourorderingdataislogged,andAmazonoffersrecommendationsbasedonyourpurchasinghistorywhenyouaccesstheirpageInotherwords,dynamicmeansthattheuserinteractswiththewebsitebeyondjustreadingpages,andthewebsiterespondsaccordinglyEverypageisapersonalizedexperienceCreatingdynamicwebpagesevenafewyearsagomeantwritingalotofcodeintheCorPerllanguages,andthencallingandexecutingthoseprogramsthroughaprocesscalledaCommonGatewayInterface(CGI)Havingtocreateexecutablefileswasn’tmuchfun,andneitherwaslearningawholenewcomplicatedlanguageThankfully,PHPandMySQLmakecreatingdynamicwebsiteseasierandfasterHTTPandtheInternetSomebasicunderstandingofhowtheInternetworksmaybeusefulifyouhaven’tprogrammedfortheWebbeforeTheHyperTextTransferProtocol(HTTP)defineshowwebpagesaretransferredacrosstheInternetHTTPisthemethodusedtotransferorconveyinformationontheWorldWideWebItsoriginalpurposewastoprovideawaytopublishandretrieveHTMLpages|Chapter:DynamicContentandtheWebTheWorldWideWebConsortium(WC)andtheInternetEngineeringTaskForcecoordinatedthedevelopmentofHTTP,whichisarequestandresponseprotocolthatconnectsclientsandserversTheoriginatingclient,usuallyawebbrowser,isreferredtoastheuseragentThedestinationserver,whichstoresorcreatesresourcesandcancontainHTMLfilesandimages,iscalledtheoriginserverBetweentheuseragentandoriginserver,theremaybeseveralintermediaries,suchasproxiesAnHTTPclientinitiatesarequestbyestablishingaTransmissionControlProtocol(TCP)connectiontoaparticularportonaremotehost(portisthedefault)AnHTTPserverlisteningonthatportwaitsfortheclienttosendarequestmessageUponreceivingtherequest,theserversendsbackastatusline,like“HTTPOK,”anditsownresponseDependingonthestatus,thisresponsecouldbetherequestedfile,anerrormessage,orsomeotherinformationHTTPisbuiltontopofTCP,whichisitselflayeredontopofInternetProtocol(IP)ThetwoareoftenreferredtotogetherasTCPIPApplicationsonnetworkedhostscanuseTCPtocreateconnectionstooneanother,andthenexchangestreamsofdataTheprotocolguaranteesreliabledeliveryofdatafromsendertoreceiverTCPsupportsmanyoftheInternet’smostpopularapplicationprotocolsandapplications,includingtheWeb,email,andSecureShell(SSH)PHPandMySQL’sPlaceinWebDevelopmentPHPisaprogramminglanguagedesignedtogeneratewebpagesinteractivelyonthecomputerservingthem,whichiscalledawebserverUnlikeHTML,wherethewebbrowserusestagsandmarkuptogenerateapage,PHPcoderunsbetweentherequestedpageandthewebserver,addingtoandchangingthebasicHTMLoutputPHPmakeswebdevelopmenteasybecauseallthecodeyouneediscontainedwithinthePHPframeworkThismeansthatthere’snoreasonforyou

职业精品

精彩专题

上传我的资料

热门资料

资料评价:

/ 430
所需积分:0 立即下载

意见
反馈

返回
顶部

Q