Thanks for your reply Anru. I'm including the template file at the end of
the 'controller'. My understanding is that including a file within another
PHP file essentially appends the code, so any variables (in the same
scope) available in the initial file should be available within the
included, yeah?

My query is more in relation to the fact that the variables don't get
output in scenarios where there is not much other code in the template. If
I add another few print statements or some html in the 'template' they do
get output. But if I have a very simple 'template' it runs without any
variables defined in the initial file seemingly being available..

Cheers
Matt

> do not know how did you injected your $main into template file from
> "controller".
>
> your can delete that line "<?php include 'header.inc.html.php'; ?>",
> to see what happen.
> I have noticed your have "html" in your file name, can you change your
> file name to "header.php"? (old MS naming style).
>
> also change include to "include_once".
>
> eclipse has a PHP plugin, which includes a step by step debugging tool.
> thought I hardly use it, but in this situation, it may help.
>
> regards,,
>
> anru
>
> On 20 November 2010 12:04, Matthew Whiting <[email protected]> wrote:
>> Kia ora all,
>>
>> Can't quite figure what is happening in a wee piece of code I'm
>> writing..
>> $main is defined in a 'controller', then the template file is included,
>> which has three lines of code:
>>
>> <?php include 'header.inc.html.php'; ?>
>> <div><?php echo $main; ?></div>
>> <?php include 'footer.inc.html.php'; ?>
>>
>> Interestingly, $main does not end up in the output, nor does another
>> variable $title that is needed in the header template. Played around a
>> little to try suss what is happening and interestingly, if I include
>> some
>> other text randomly in this template (but has to be more than just a
>> word or
>> two), $main does get output e.g.
>>
>> <?php include 'header.inc.html.php'; ?>
>> blah blah blah blah blah blah blah blah
>> <div><?php echo $main; ?></div>
>> <?php include 'footer.inc.html.php'; ?>
>>
>> Any suggestions as to what might be going on here? Also, ideas as to
>> useful
>> debugging tools in this type of scenario would be helpful..
>>
>> Cheers
>> Matt
>>
>>
>> --
>> NZ PHP Users Group: http://groups.google.com/group/nzphpug
>> To post, send email to [email protected]
>> To unsubscribe, send email to
>> [email protected]
>
> --
> NZ PHP Users Group: http://groups.google.com/group/nzphpug
> To post, send email to [email protected]
> To unsubscribe, send email to
> [email protected]
>


-- 
NZ PHP Users Group: http://groups.google.com/group/nzphpug
To post, send email to [email protected]
To unsubscribe, send email to
[email protected]

Reply via email to