Posted by Schraalhans Keukenmeester on 05/15/07 00:01
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.
[Back to original message]
|