55Chapter 4Adding PHP to HTMLIf you ve made the (Web hosts)

55Chapter 4Adding PHP to HTMLIf you ve made the virtuous decision to eschew the short-open tag, remember to disable it inyour php.inifile. You want to see an error message when you inadvertently forget to com- plete your tag correctly. ASP-style tagsASP-style tags mimic the tags used by Microsoft Active Server Pages to delineate code blocks. ASP-style tags look like this: <% %> People who use FrontPage as a development tool often choose this style. To use ASP-styletags, you will need to set the configuration option in your php.inifile. Obviously, if you useASP-style tags and the .aspsuffix (which you may wish to do if you re converting from anASP site or spoofing ASP for some reason), you will need to disable ASP on your IIS server. Otherwise, two different scripting engines will be trying to parse the same blocks of codewith unpredictable results. HTML script tagsHTML script tags look like this: Although this is effective and also gets around the FrontPage problems, it can be cumber- some in certain situations, such as quick pop-in variable replacement. In particular, be carefulif you use lots of JavaScript on your site since the close-script tags are fatally ambiguous. TheHTML script tag is best used for fairly sizable blocks of PHP code. Hello WorldNow we re ready to write our first PHP program. Open a new file in your preferred editor. Type: My first PHP program
n ); phpinfo(); ?> In most browsers, nothing but the PHP section is strictly necessary. However, it s a good ideato get in the habit of always using a well-formed HTML structure in which to embed your PHP. If you don t see something pretty close to the output shown in Figure 4-1, you have a problem most likely some kind of installation or configuration glitch. Review Chapter 3, and make doublysure your installation succeeded. Tip06
Note: In case you are looking for affordable and reliable webhost to host and run your business application check Vision php5 hosting services

Leave a Reply