By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,510 Members | 1,821 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,510 IT Pros & Developers. It's quick & easy.

Quick question regarding basic template

P: n/a
Below I have some code and below that a template file which I want to use to
display the message lines. I just get a blank page so are the functions
"getMessageLine1" and "getMessageLine2" returning objects and not strings?
Just wondering how I work around this.

Cheers

Phil
-------- HelloWorld3.php ----------
<?php

$newClass = new PrintMessage("Hello World", "Yet another Hello World");

include("HelloWorld03.tpl.php");

class PrintMessage
{
private $messageLine1;
private $messageLine2;

function __construct($messageLine1, $messageLine2)
{
$this->messageLine1 = $messageLine1;
$this->messageLine2 = $messageLine2;
}

function getMessageLine1()
{
return $this->messageLine1;
}

function getMessageLine2()
{
return $this->messageLine2;
}
}
?>

------ HelloWorld03.tpl.php -------
<html>
<head>
<title>This is HelloWorld03.tpl.php</title>
</head>
<body>
<?php echo $newClass->getMessageLine1; ?>
<br />
<?php echo $newClass->getMessageLine2; ?>
</body>
</html>
May 14 '07 #1
Share this Question
Share on Google+
4 Replies


P: n/a
At Mon, 14 May 2007 23:32:43 +0000, Phil Latio let his monkeys type:
Below I have some code and below that a template file which I want to
use to display the message lines. I just get a blank page so are the
functions "getMessageLine1" and "getMessageLine2" returning objects and
not strings? Just wondering how I work around this.

Cheers

Phil
-------- HelloWorld3.php ----------
<?php

$newClass = new PrintMessage("Hello World", "Yet another Hello World");

include("HelloWorld03.tpl.php");

class PrintMessage
{
private $messageLine1;
private $messageLine2;

function __construct($messageLine1, $messageLine2) {
$this->messageLine1 = $messageLine1;
$this->messageLine2 = $messageLine2;
}

function getMessageLine1()
{
return $this->messageLine1;
}

function getMessageLine2()
{
return $this->messageLine2;
}
}
?>

------ HelloWorld03.tpl.php -------
<html>
<head>
<title>This is HelloWorld03.tpl.php</title</head>
<body>
<?php echo $newClass->getMessageLine1; ?<br />
<?php echo $newClass->getMessageLine2; ?</body>
</html>
Parentheses are missing in the template file. You are echoing a
non-existent object variable instead of a function value;

<?php echo $newClass->getMessageLine1(); ?<?php echo
$newClass->getMessageLine2(); ?>

HTH
Sh.
May 15 '07 #2

P: n/a
Parentheses are missing in the template file. You are echoing a
non-existent object variable instead of a function value;

<?php echo $newClass->getMessageLine1(); ?<?php echo
$newClass->getMessageLine2(); ?>

HTH
Sh.
Many thanks. What a chump I am. :))

Cheers

Phil
May 15 '07 #3

P: n/a
At Tue, 15 May 2007 00:05:53 +0000, Phil Latio let his monkeys type:
>Parentheses are missing in the template file. You are echoing a
non-existent object variable instead of a function value;

<?php echo $newClass->getMessageLine1(); ?<?php echo
$newClass->getMessageLine2(); ?>

HTH
Sh.

Many thanks. What a chump I am. :))

Cheers

Phil
No problem, you are in good company (referring to myself, in case anyone
felt insulted). One of those typos my editor doesn't spot.
Today I spent half an hour finding a simple typo as well. I put an l where
a 1 was intended. Stooopid!

Rgds
Sh.
May 15 '07 #4

P: n/a
Schraalhans Keukenmeester wrote:
No problem, you are in good company (referring to myself, in case anyone
felt insulted). One of those typos my editor doesn't spot.
Oh yes, I've done that too -- it's a very easy mistake to make. It's one
of the first things I check for now when I've got a mysterious bug. (Right
after a missing semicolon!)

--
Toby A Inkster BSc (Hons) ARCS
http://tobyinkster.co.uk/
Geek of ~ HTML/SQL/Perl/PHP/Python/Apache/Linux
May 15 '07 #5

This discussion thread is closed

Replies have been disabled for this discussion.