Hi.
I have just finished an example in a book and I have literally copied the PHP word for word and I get this error:
Parse error: parse error, unexpected $end in c:\apache\htdocs\sp\ch2\example 2.4.3_5.3.php on line 63.
All other PHP scripts I have written work perfectly.
I am running Apache server 1.3.29 with PHP 4.3.4 under Windows 98 SE. I don't see why there should be a problem...
What's wrong?
Many thanks,
Jon
<?php
// Page class
class Page {
// Declare a class member variable
var $page;
// The constructor function
function Page()
{
$this->page = ' ';
}
// Generates the top of the page
function addHeader($title)
{
$this->page .= <<<EOD
<html>
<head>
<title>$title</title>
</head>
<body>
<h1 align="center">$title</h1>
EOD;
}
// Adds some text to the page
function addContent($content)
{
$this->page .= $content;
}
// Generates the bottom of the page
function addFooter($year, $copyright)
{
$this->page .= <<<EOD
<div align="center">© $year $copyright</div>
</body>
</html>
EOD;
}
// Gets the contents of the page
function get()
{
return $this->page;
}
}
// Instantiate the Page class
$webPage = new Page();
// Add the header to the page
$webPage->addHeader('A Page Built with an Object');
// Add something to the body of the page
$webPage->addContent("<p align=\"center\">This page was " . "generated using an object</p>\n");
// Add the footer to the page
$webPage->addFooter(date('Y'), 'Object Designs Inc.');
// Display the page
echo $webPage->get();
?>