473,383 Members | 1,788 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

Quick question regarding basic template

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
4 1237
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: LW | last post by:
I'm using the following free implementation of an XSLT "split" function, as a template: http://www.exslt.org/str/functions/split/str.split.template.xsl.html Basically, it allows me to call it...
6
by: Lasse Skyum | last post by:
Hi All, Is it possible to detect (at compile-time) if an item is a basic type (int, float, double,...) or an instance of a class/struct? I'm thinking something like: (obviosly this isn't...
13
by: Winbatch | last post by:
Hi, If this should be directed to another group, please let me know... I've been working with templates for a few weeks and have been able to develop some nice code on solaris using the Forte C++...
3
by: darkstorm | last post by:
I have a doubt regarding inheritance involving templates Consider this: ///////////////////////////////////// template<typename T> class A { private: T m_a;
2
by: toton | last post by:
Hi, This is a silly question related to syntax only. I have a template class with template member function, How to write it separately in a file (not translation unit, just want to separate...
4
by: Goran Djuranovic | last post by:
Hi all, I am experiencing a strange thing happening with a "designer.vb" page. Controls I manually declare in this page are automatically deleted after I drop another control on a ".aspx" page. -...
1
by: ju21 | last post by:
Hi friends, The following snippet works fine with C++ compilation whereas it fails when I compile in linux. The function toWString returns a WString. template<class T> const wstring toWString(T...
9
by: Peskov Dmitry | last post by:
It is a very basic question.Surely i got something wrong in my basic understanding. //Contents of file1.cpp using namespace std; #include <iostream> template <typename T> class my_stack;
16
by: PeterAPIIT | last post by:
Hello all C++ expert programmer, i have wrote partial general allocator for my container. After reading standard C++ library and code guru article, i have several questions. 1. Why...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.