Re: Variable scope problem?
"J" <notanymore> wrote:
> I tried using $GLOBALS['KTPTBlue']; perhaps I didn't do it right.
> The global keyword gives me an error...expected = or something.
>
guess so I would have expected it to.
>
> ****************TOP.PHP
> <?
> require_once("KTConstants.php");
> require_once("PatientResults.php");
> require_once("BuildForm.php");
> require_once("Bottom.php");
>
required/included files are added in the global scope
> function Top($redorblue)
> {
> //if ( $redorblue == 'red')
I guess you don't really mean to comment this line only - cos that would be
a syntax error
> $KTPTTopColor=$KTPTRed;
> else
> $KTPTTopColor=$KTPTBlue;
>
These variables are all out of scope.
Should be:
$KTPTTopColor=$_GLOBALS['KTPTRed'];
> echo $KTPTBlue; //Doesn't work
> echo $KTPTTopColor; //Doesn't work
>
Yes - its out of scope.
C.
|