[FX.php List] Returning FX Object From Function
Charles Ross
chivalry at mac.com
Sat Dec 10 01:45:29 MST 2005
Greg,
Thanks for the welcome and the info. I should have probably figured
that one out, but I was so used to using with abandon variables
declared in an included file that I didn't think of scope as an issue
within the function.
Interestingly, your recommendation didn't work. However, using the
$GLOBALS array did. I changed the function to read as:
function NewFX($layout)
{
$fxphp = new FX($GLOBALS[serverIP], $GLOBALS[webCompanionPort]);
$fxphp->SetDBData($GLOBALS[laurelFile], $layout);
$fxphp->SetDBPassword($GLOBALS[webPW], $GLOBALS[webUN]);
return $fxphp;
}
and it worked. Placing the line you suggested didn't work.
This possible solution was pointed out to me in the documentation at
the link you provided. Thanks very much.
Chuck
On Dec 9, 2005, at 11:00 PM, Greg Lane wrote:
> Welcome Chuck!
>
> The variables (except $layout) inside your NewFX function don't
> contain the values you might expect. Try adding the following line
> to your function, immediately after the "{" line:
>
> global $serverIP, $webCompanionPort, $laurelFile, $webPW, $webUN;
>
> Variables inside of a function have a local scope unless you've
> specified otherwise. See the PHP manual page on variable scope for
> more info <http://us3.php.net/manual/en/language.variables.scope.php>.
>
> Greg
>
>
> On Dec 9, 2005, at 8:53 PM, Charles Ross wrote:
>
>> My thought was to create a function to perform these three lines
>> of code:
>>
>> function NewFX($layout)
>> {
>> $fxphp = new FX($serverIP, $webCompanionPort);
>> $fxphp->SetDBData($laurelFile, $layout);
>> $fxphp->SetDBPassword($webPW, $webUN);
>>
>> return $fxphp;
>> }
>
> _______________________________________________
> FX.php_List mailing list
> FX.php_List at mail.iviking.org
> http://www.iviking.org/mailman/listinfo/fx.php_list
More information about the FX.php_List
mailing list