Page 1 of 1

UDTs are being silly

Posted: Wed Jun 20, 2007 11:43 am
by Cobby
Hi all,

Here is my problem.

If I have a tag called {page} and its contents is:

Code: Select all

$p = "1";
$page[$p] = "This is page ".$p;
$p++;
echo $page[1];
echo $page[2];
It will output:
This is page 1This is page 2

But if I put $p into a separate tag, so I hade
{p}

Code: Select all

$p = "1";
and

{page}

Code: Select all

$page[$p] = "This is page ".$p;
$p++;
echo $page[1];
echo $page[2];
If that happens it will only output:
This is page 1

I am entering {p}{page} into the page, so that is correct.

Why does it only output 1 page when I set $p in its own tag?

Does tags not recognize the value of variable from another tag?

Cheers,
Cobby

Re: UDTs are being silly

Posted: Wed Jun 20, 2007 7:12 pm
by calguy1000
it's not being silly, it's a matter of scope.  if you want to access variables from one UDT in another, you will need to make that variable global in scope.

Re: UDTs are being silly

Posted: Thu Jun 21, 2007 12:02 am
by Cobby
Thanks for that. Much appreciated :)