Professional Documents
Culture Documents
Ch05 PHP Excerpt
Ch05 PHP Excerpt
Hello, world!
Your full name is = $fullname ?>
Halo, world! ‘You fillnzane is Victoria Kiss, Example 5.45 Scope across PHP blocks 5.4.2 Including Files PHP has a function named include that you can use to inject a file's contents into your page. IF the injected file's contents are HTML code, the HTML is displayed on your page. If its contents are PHP code, the code will be executed, and any variables or functions it declares will now be available to any of your subsequent code. The following is the syntax for the include function: include(“filename"); Example 5.46 Syntax template for include statement ‘You can include as a powerful way to climinate redundancy at the file level you may have several pages that (Or you may have written useful utility functions and code that you'd like to call in several pages. In either case, you can place the common content into a separate file and have each page include it Suppose you have two pieces of important HTML and PHP code whose content you want to in clude in several pages on your overall web site. The first reused piece of code is a quote from a poem, and a function called pigLatin that you want to call in several pages. You can put this partial web content into a file such as partial php shown in Example 5. 1c example,« $word[@] . “ay Example 5.47 Partial web page, partial1.phpI think that I shall never see
A poem lovely as a tree