Web hosting ratings - PHP SOLUTIONS: DYNAMIC WEB DESIGN MADE EASY You
PHP SOLUTIONS: DYNAMIC WEB DESIGN MADE EASY You can have as many PHP code blocks as you like on a page, but they cannot be nested inside each other. Figure 3-1 shows a block of PHP code embedded in an ordinary web page and what it looks like in a browser and page source view after it has been passed through the PHP engine. The code calculates the current year, checks whether it s different from a fixed year (represented by $startYear in line 32 of the code on the left of the figure), and displays the appropriate year range in a copyright statement. As you can see from the page source view at the bottom right of the figure, there s no trace of PHP in what s sent to the browser. The only clue that PHP has been used to generate that part of the page lies in the whitespace between the date range and the surrounding text, but that doesn t affect the way it s displayed because browsers ignore anything more than a single space in XHTML. Figure 3-1. Output from PHP is normally displayed in the same place as it is embedded in the XHTML code. PHP doesn t always produce direct output for the browser. It may, for instance, check the contents of form input before sending an email message or inserting information into a database. So some code blocks are placed above or below the main XHTML code. Code that produces direct output, however, always goes where you want the output to be displayed. Using variables to represent changing values The code in Figure 3-1 probably looks like an awfully long-winded way to display a range of years. Surely it s much simpler to just type out the actual dates? Yes, it is, but the PHP
We would like to recommend you tested and proved virtual web hosting services, which you will surely find to be of great quality.