Search Help Board

PHP FAQ
PHP Articles
PHP Help
Bulletin Board

PHP Manual (NEW!)
First Time PHP'ers
Help with programming
Sql assignment help
PHP Homework Help


 

Previous Page Page 2 of 5 Next Page

HTML Output

We begin by entering the following PHP code into a file, saving it as filename.php3 and then accessing the saved file with a web browser.  If your web server supports PHP it will display the string "Hello!".

PHP Code:

<?php

echo "<html><body>";
echo "Hello!";
echo "</body></html>";

?>

Web Browser Result:

Hello!

Below is a description of the important keywords used in this example.

<?php and ?>
These tags are used to denote a block of PHP code.  In order for the web server to process PHP code, you must tell it where a block of PHP code begins and ends.  By default a PHP file will start in HTML mode; meaning you can put HTML in a PHP file and it will be executed normally.

The above example, could also be written like this:

PHP Code:

<html><body>
<?php
echo "Hello!";
?>
</body></html>

echo
This command outputs a string to the HTML browser.

; (the semicolon)
Each PHP instruction must end with a semicolon.  Note: one instruction can span more than one line.

PHP Code:

echo "
<html><body>
Hello!
</body></html>
" ;

Previous Page Page 2 of 5 Next Page