INTRODUCTION

Site Home
LAMP Home
PHP Web Home
Server Setup
nav.php
code.php
Download Tutorial

LESSONS

01 Hello World!
02 Text I/O
03 Arithmetic
04 Date and Time
05 Image Creation
06 Pie Chart
07 Array and Records
08 Delete a Record
09 Shopping
10 Shop Checkout
11 MM Bingo

MORE PHP

PHP Console Apps
PHP and MySQL

01 - Text Output Using PHP

Hello World!

As far as possible, PHP processing (business rules) should be carried out before the <head> tag on a web page. In the <body> of the page, there should only be echo, include and other output statements.

Homework: Write your own version of the "Hello World!" program. It should display several pieces of text and should include formatting tags such as headings and paragraphs.


<!-- Here is the page source code for 01hello.php -->

<?php
  include "code.php";    // Contains the function used to display
                         // the source code of web pages.
  
  $helloMessage = "<h3>Hello World!</h3>";
?>

<html>
<head>
<title>Text Output Using PHP</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="style.css" rel="stylesheet" type="text/css">
</head>

<body>
<table border="1" cellpadding="4" cellspacing="0">
<tr valign="top">
<td><?php include "nav.php"; ?></td>
<td>
<h1>01 - Text Output Using PHP</h1>

<?php echo $helloMessage; ?>

<p> As far as possible, PHP processing (business rules) should be carried out 
        before the &lt;head&gt; tag on a web page. In the &lt;body&gt; of the 
        page, there should only be echo, include and other output statements.</p>
      <p><strong><font color="#FF0000">Homework:</font></strong> Write your own 
        version of the &quot;Hello World!&quot; program. It should display several 
        pieces of text and should include formatting tags such as headings and 
        paragraphs.</p>

<?php dump_page("01hello.php"); ?>
</td>
</tr>
</table>

</body>
</html>