Well, that's just a typo...of course there should be a () to make it call a
function...

The whole point to my postings is that I can't get the darn variable to stay
in place!!! Look where it says "Prints NOTHING".

Does anyone know why it doesn't print "Hello World"???

::Lewis


"Mike Ford" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> > -----Original Message-----
> > From: OrangeHairedBoy [mailto:[EMAIL PROTECTED]]
> > Sent: 03 October 2002 09:39
> >
> > Here's a simplier version...and I'm still having a problem
> > with it. It's
> > driving me insane!!! :)
> >
> > class MySQL
> >  {
> >  function SET ( )
> >   {
> >   $this->MYVAR = "Hello World!";
> >   }
> >  function RETREIVE ( )
> >   {
> >   print $this->MYVAR;
> >   }
> >  }
> > $helpme = new MySQL;
> > $helpme->SET;
> > $helpme->RETREIVE; /* Prints NOTHING */
>
> I'm pretty sure you have to add () on the end of those function names to
get
> PHP to actually *call* the function, so you need:
>
>   $helpme->SET();
>   $helpme->RETREIVE();
>
> Without the parentheses, PHP evaluates the name of the function (returning
> its "handle"), but then doesn't know what to do with it so just throws it
> away on seeing the terminating semicolon.  As far as PHP is concerned, you
> could quite legitimately want to do something entirely different with the
> handle, such as assigning it to a variable -- PHP won't assume you want to
> call it as a function just because it happens to be a function name.  For
> instance, the following should work (I think! - although I haven't tested
> it):
>
>   $method = $helpme->SET;
>   $method();
>
> In fact, you can ask PHP to try and call anything as a function by
appending
> parentheses, so this should work too:
>
>   $method = "SET";
>   $helpme->$method();
>
>
> Cheers!
>
> Mike
>
> ---------------------------------------------------------------------
> Mike Ford,  Electronic Information Services Adviser,
> Learning Support Services, Learning & Information Services,
> JG125, James Graham Building, Leeds Metropolitan University,
> Beckett Park, LEEDS,  LS6 3QS,  United Kingdom
> Email: [EMAIL PROTECTED]
> Tel: +44 113 283 2600 extn 4730      Fax:  +44 113 283 3211



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to