FRIHOSTFORUMSSEARCHFAQTOSBLOGSCOMPETITIONS
You are invited to Log in or Register a free Frihost Account!


[Resolved] Object Orientated PHP errors





thnn
I created this class and saved it as classes.php. I then create a file called index.php which includes a file that sets the variables. And I have made a file which sets the variables to be displayed. The classes.php file is included through the environment file which is included on the index page at the top. Then when i run the index.php it doesnt work.I am given the error Fatal error: Call to a member function DisplayTitle() on a non-object in Z:\oop\classes.php on line 39

Contents of classes.php
<?
/* - - - - - - - - - - - - - - - - - - - - - - -
@files classes.php
@purpose builds the page dynamically
@package THNN Website Software
@version 2.0
@copyright (C)2005 Totally Hogwarts News Network. All rights reserved.
- - - - - - - - - - - - - - - - - - - - - - - */
class page
{
// class Page's attributes
var $content;
var $title;

//class Pages' operations

function SetContent($pagecontent)
{
$page->content = $pagecontent;
}

function SetTitle($pagetitle)
{
$page->title = $pagetitle;
}

function DisplayTitle()
{
echo "<title>Totally Hogwarts News Network $page->title </title>";
}

function DisplayStyles()
{
echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"layout/style.css\">";
}

function DisplayHeaders()
{
$page -> DisplayTitle();
$page -> DisplayStyles();
}

function DisplayPage()
{
echo $page->content;
}

function IsURLCurrentPage($url)
{
if(strpos( $GLOBALS['SCRIPT_NAME'], $url) == false)
{
return false;
}
else
{
return true;
}
}
}
?>

Contents of index.php

<?php
require ("Z:\environment.php");
$homepage = new page();
if (isset($_GET['m'])==false)
{
$include = 'news.php';
require($include);
}
else
{
$module = $_GET['m'];
$include = "modules/".$module.".php";
if (is_file($include)==true)
{
require($include);
}
else
{
$homepage -> SetContent('Page not found');
}
}
?>
<html>
<head>
<?php
$homepage -> DisplayHeaders();
?>
</head>

<body>
<?php
$homepage -> DisplayPage();
?>
</body>
</html>

Contents of news.php

<?php
$homepage -> SetTitle('Banana');
$homepage -> SetContent('Hey');
?>

Any help would be appreciated.

Thanks
Related topics
My 3 sites, hosted by FriHost.
My BBS
[Official] Best PHP Editor
Content management systems
uma grande dúvida em php, por favor me ajudem
My first Visual Basic program!
PlusContact 1.4
Network Question..Router/switch/hub
Any suggestion on add-on services that work with Frihost?
BlueFeather OS
Why not php 5?
Two PHP Errors
PHP Errors
Forcing PHP error reporting
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.