Afficher un message
Vieux 27/02/2008, 00h21   #3
Rik Wasmus
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Question regarding variable scope, static class functions, and pass by reference

On Tue, 26 Feb 2008 19:38:37 +0100, Logos <tyler.style@gmail.com> wrote:

> I've run into an interesting issue. I am calling a static member of a
> class, and passing in by reference the variable $oCust. I would like
> to have an object instantiatee & assigned to this variable (see code
> snippets below). The object is definitely being instantiated, I check
> right after I create it and again before the function returns.
> However, back in the main thread after the function returns, $oCust
> has not been assigned anything...
>
> Why should this be? Is there some scope issue that I'm not aware of?
>
> Thanks for looking...
>
> Tyler
>
>
> ================================================== =====
> $oCust =NULL;
> ...
> DAL::setCust(COMPANY_ID_DEFAULT, $sUsername, $sPassword, $oCust);

---------------^1------------------^2----------^3----------^4

> ================================================== =====
> public static function setCust($iCompanyId, $iCustId, &$oCust) {

---------------------------------^1-----------^2--------^3

Where's the password? That's the one being done by reference. It doesn't
matter how you name your variables when calling:
Funtion = caller:
$iComanyid = COMPANY_ID_DEFAULT
$iCustId = $sUsername
$oCust = $sPassword
....which leaves a 4th variable, with which the function does nothing,
nada, so it's NULL all the way.
--
Rik Wasmus
  Réponse avec citation
 
Page generated in 0,05984 seconds with 9 queries