Hey I'm a php beginner and I'm having some problems with the website I'm testing with. I'll show you first the relevant code.
index.php:
<?php
include "stdlib.php";
$page = new Page();
$page->title = "Index";
$page->printHeader();
?>
<style type="text/css">
div.container
{
width:100%;
margin:0px;
border:1px solid gray;
}
div.left
{
width:100px;
float:left;
padding:1em;
margin:0;
}
div.content
{
margin-left:190px;
border-left:1px solid gray;
padding:1em;
}
</style>
<div class="container">
<div class="left"><p class="left">Seth Baur</p></div>
<div class="content">
<p>Welcome to my site.</p>
<?php echo date("d-m-Y"); ?>
<form action="form.php" method="post">
Name: <input type="text" name="name" /><br />
Age: <input type="text" name="age" /><br />
<input type="submit" />
</form>
</div>
</div>
<?php
$page->printFooter();
?>
stdlib.php:
<?php
function __autoload($class_name){
require_once $class_name . '.php';
}
?>
Page.php:
<?php
class Page {
var $title;
function printHeader() {
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<link rel="stylesheet" type="text/css" href="styles.css" />
<title><?php echo $this->title; ?></title>
</head>
<body>
<?php
}
function printFooter() {
?>
</body>
</html>
<?php
}
}
?>
The error I'm getting now that I've put in the autoload function is:
Fatal error: Cannot instantiate non-existent class: page in /home/content/t/h/r/threepio/html/seth/php/index.php on line 3
All of these files are in the same directory, so I'm not sure why it can't find the Page class. Anyone have an idea?