Hi all,

I'm currently trying to implement a PayPal PHP SDK. Not the easiest thing, with very poor documentation imo.
Anyway, I've got a 'general' php question.

the error:

Notice: Only variables should be assigned by reference in /home/bla/public_html/api/testScript.php on line 68

line 68

$profile =& APIProfile::getInstance($apiusername, $handler); //$apiusername and  $handler both have a value

isn't $profile considered a variable? i guess i really don't understand what the error is telling me. i've tried to google this error, but nothing informative (to me anyway) was returned.

Any ideas?

Thanks.

    Yes, but APIProfile::getInstance($apiusername, $handler) (or, more precisely, its return value) is not. That is what you're assigning; $profile is what you're assigning to.

    See the page on returning [man]references[/man] (especially the two notes on the "Returning References" page). The declaration of the getInstance method should have a & in it as well; i.e., written as "function &getInstance(....)".

      interesting. thanks for the info Weedpacket.

      then what about just removing the reference asignment:

      $profile = APIProfile::getInstance($apiusername, $handler);
      

      ??

      Both seem to 'remove' the error, I just don't know if both are just as 'acceptable' as the other, etc.

        Well, if it works..... certainly there'd be no need for them in PHP5 (since the method obviously constructs and returns a Profile object).

          Write a Reply...