Now let's use this strange ideas with classes and functions an create something like a page class.
Filename: class.page.php
<?php
class page
{
function head()
{
print "<html>\n";
print "<body>\n";
}
function foot()
{
print "</body>\n";
print "</html>\n";
}
}
?>
In this class we have two functions, one called head and one called foot. The idea is to call head at the beginning to create a page head, and the foot is supposed to be called at the end. Adding the necessary html tags to make it a valid html page.
We can do this in all php.
Filename: p03_ex01.php
<?php
require_once("class.page.php");
$page = new page();
$page->head();
print "<p>Just a little page</p>\n";
$page->foot();
?>
Or we can mix php and html.
Filename: p03_ex02.php
<?php
require_once("class.page.php");
$page = new page();
$page->head();
?>
<p>Just a little page</p>
<?php
$page->foot();
?>
Notice that both example does exactly the same thing, so it is a matter of taste what to use.