PHPwilltakeinformationfromWebformsanddumpthatinformationintodatabasesorfiles, Anditcanreadfromdatabasesandfileseitheroutportoutputto a Webpageoroutputtosomethinglike a textfile.
SobeingabletoprintfromdatabasesbeingabletoprintfromPHPscriptsis a veryimportantthingnow.
Soifit's alsoimportanttothinkaboutwhenyou'relearning, PHPistothinkabouthowtoformattheoutputofyourcodeinsuch a waythatifthereareerrors, youcangoandyoucaninspectthecode.
Andit's easierforyoutoseewhat's goingoninthebackendsothatlet's goovertothecomputerand I canshowyouhowprintandthenewlinecommandworkswhenyou'reprintingoutwhenyou'reusingPHP.
Sohere's a simplescriptusingtheprintoffunctioninPHP, wehavethreedifferentexampleshere.
Thefirstexampleis, waswhereweresimplyusingprint.
Thesecondexampleiswe'reusingprint, butwe'realsousingtheNewLinecommandattheendofeverysentenceandinthefinaloneiswhere I showyouhowyoucanuseNewLinekindofbestupidifyouwantto, justtorealisewhatextremeyoucangoto.
Sobasicallyuphere, we'retaking a lookatthisandwehavethetitleforthisparticularexample.
Andsoit's importantwhenyoutake a lookatthiswithhowthisisonthepage, how I wrotethiscode, youwanttothinkabouthowyouthinkthisisgoingtobeprintedout, bothanhtmlinandintext.
We'llshowyoutheexampleon a minute.
Once I gothroughtheothercodethatwehavehere, wethencomedownhereforthisparticularpage.
Wehave H onePHPprintwiththeNewLinecommandexample, andsoagainwecallPHP.
Soinsteadofhavingeverythingjustgetprintedacrossononecontinuousline, usingtheendashowyoucanbreakandyoucangotothenextlinetoshowyou a ridiculousexampleofthiswehavethe H onestupidnewlinecommandops, stupidnewlinecommandexample.
AndwhatyouhavedownhereisagainwecallPHP.
Wethendoprintspace, doublequotation, andthen, well, youcanseehereisbasicallyaftereveryletter I putthatnewlinecommandinsothatitwillgotothenextlineinnextline.
AndyoumightbeconfusedherebecauseyouseethePHPprintexample H oneandthenyouseeprintitemoneprintitemtoprintitemthreeandtheseareallinthesamethesamerow, sothatprobablymakessensetoyou.
Soalthoughyoudon't seethisusing a Webbrowser, thisishowitlookswhenyousee a texteditor, Thenwhenwecomedownwhenwetake a lookatthestupidexample, that's whenyougetthisstupidmessdownhere.
Basicallyagain, weprintedeachindividualletteron a differentline, eventhoughwhenwegohere, wedon't seetheexactsamething.
Sothisistheimportantthingtounderstandwhenyou'reusingprintandwhenyou'reusingthenewlinecommand, whatyouprintouttoe a textfileisnotnecessarilywhattheWebbrowserwillsee.
Ifyouwanttoput a newlinewithintheprintfunction, youjustdobackslashendwhereveryouwantthatnewline, andthenitwillprinteverythingoutinthetextfileasthebasictext.
SoifyouviewcodeyourPHPscriptinsuch a waythatitoutputs a sourcethat's easytoreadthatwillmakeyourlife a loteasier, especiallyinthebeginning, whenyou'retryingtotroubleshootyourcodeagain.