[...]... existed 14 Chapter 1: Welcome to PHP .php > PHP By Example :: Chapter 1 :: Example 1/title> PHP By Example :: Chapter 1 :: Example 1 < ?php /* Display a text message */ HTML START TAG echo "Hello, world! This is my first PHP program."; CODE / COMMANDS ?> END TAG PHP HTML Figure 1.1: This diagram... they are completely ignored by PHP EXAMPLE Comments can be done either of two ways: single line or multiline The one you pick depends on what you want to comment out The following example is a file header using multiline comments that might be found in a PHP program file: Writing a Basic PHP Program 19 < ?php /* + -+ | example_ file .php – serves as a good example | + ... statements that PHP will be able to interpret and carry out Examples of this are PHP s opening and closing tags PHP only parses code that is between PHP tags Anything else in the file is returned as part of the HTML page, just as seen earlier in the first example Here’s another example The following statement does not work, even though the command is part of PHP s language: echo “This won’t work.” EXAMPLE. .. principle: EXAMPLE < ?php /* ch01ex03 .php – program to show usefulness of indenting */ if ($gotPHP) { echo “Got PHP? ”; if ($PHPMustache) { echo “ :)”; } } ?> Even though you haven’t really learned anything about the statements this program uses, you can easily see how everything follows a form similar to that of an outline Also, the separation of echo “Got PHP? ”; and if ($PHPMustache) { by a blank line... file does contain PHP code, so it must be named with a php extension The PHP code lies between the PHP tags (< ?php and ?>) as shown in Figure 1.1 The command between the PHP tags is echo (PHP s word for “add the following text to the page”) followed by the text to display The output, which will be shown soon, looks just as if the text after echo had been in an HTML file itself and no PHP code ever existed... response from the server EXAMPLE Now that you’ve seen the overall process, let’s take a look at our first PHP program After reading the following example, you’ll learn what separates it from a normal HTML file, how to upload it to your Web server, and what the page should look like viewed in your browser .php > PHP By Example :: Chapter 1 :: Example 1... Apache if it’s not already installed Apache is available at www.apache.org • PHP The PHP interpreter is necessary so you can run your PHP programs Users of PHPTriad for Windows can skip this step; PHPTriad installs a Web server, PHP, and even MySQL all in one step For those who don’t already have PHP installed, go to www .php. net/manual and read the appropriate instructions for your operating system... bgcolor=”white” text=”black”> PHP By Example :: Chapter 1 :: Example 1 < ?php /* Display a text message */ echo “Hello, world! This is my first PHP program.”; ?> This file looks a lot like a regular HTML file Notice that the file has HTML tags typical of those you would find in any HTML file In fact, if you disregard everything between the < ?php and ?> tags, you might as well... because a lot of the time you don’t even know specifically what you’re looking for Chapter by Chapter Part I of this book, “Getting Started with Programming in PHP, ” introduces you to the beginning concepts of PHP programming In Chapter 1, “Welcome to PHP, ” you’ll create your first PHP program by following simple step -by- step instructions If your program doesn’t work right away, don’t worry—a troubleshooting... that PHP code must be enclosed in the < ?php and ?> PHP tags Using tags to separate PHP code and HTML code within the same file allows programming code to be mixed directly with information that is going to be sent to the browser just as it is This makes PHP an embedded programming language because PHP code is embedded directly in HTML code This concept is relatively new: Before languages like PHP, . Indiana 46290 BY EXAMPLE Toby Butzon PHP PHP By Example Copyright© 2002 by Que All rights reserved. No part of this book shall be reproduced, stored in a retrieval system, or transmitted by any means,. advised to get PHPTriad at www.phpgeek.com/phptriad. Users of Unix-based systems should install Apache if it’s not already installed. Apache is available at www.apache.org. PHP. The PHP interpreter. can run your PHP pro- grams. Users of PHPTriad for Windows can skip this step; PHPTriad installs a Web server, PHP, and even MySQL all in one step. For those who don’t already have PHP installed,