Disney web site - 80Part IPHP: The BasicsIn addition to single-quotes and

80Part IPHP: The BasicsIn addition to single-quotes and double-quotes, there is another way to create strings (calledthe heredocsyntax), which in some ways makes it even easier to splice in the values of vari- ables. We cover it in Chapter 8. Newlines in stringsAlthough PHP offers an escape sequence (n) for newline characters, it is good to know thatyou can literally include new lines in the middle of strings, which PHP also treats as a newlinecharacters. This capability turns out to be convenient when creating HTML strings, becausebrowsers will ignore the line breaks anyway, so we can format our strings with line breaks tomake our PHP code lines short: print( My HTML page is too bigto fit on a single line, but that doesn t mean that Ineed multiple print statements! ); We produced this statement in our text editor by literally hitting the Enter key at the end of thefirst two lines these newlines are preserved in the string, so the single printstatement willproduce three distinct lines of PHP output. (Your mileage may vary depending on your text editor if your editor automatically wraps lines in displaying them, you may see three lines ofcode that are actually one long line.) Of course, the browser program will ignore these newlinesand will make its own decisions about whether and where to break the lines in display, but youwill see the linebreaks if you use View Source in your browser to see the HTML itself. LimitsThere are no artificial limits on string length within the bounds of available memory, youought to be able to make arbitrarily long strings. OutputMost of the constructs in the PHP language execute silently they don t print anything tooutput. The only way that your embedded PHP code will display anything in a user s browserprogram is either by means of statements that print something to output or by calling func- tions that, in turn, call printstatements. Echo and printThe two most basic constructs for printing to output are echoand print. Their language status is somewhat confusing, because they are basic constructs of the PHP language, ratherthan being functions. As a result, they can be used either with parentheses or without them. (Function calls always have the name of the function first, followed by a parenthesized list ofthe arguments to the function.) EchoThe simplest use of echois to print a string as argument, for example: echo This will print in the user s browser window. ; Or equivalently: echo( This will print in the user s browser window. ); Cross- Reference07
If you are looking for affordable and reliable webhost to host and run your business application visit our ftp web hosting services.

Leave a Reply