thank, sure. function name should be myClassGetVar() :)

/tom

On Mon, 15 Mar 2004 14:49:55 +0100
Marco Schuler <[EMAIL PROTECTED]> wrote:

> Hi
> 
> Am Mo, 2004-03-15 um 14.10 schrieb Tom Meinlschmidt:
> > I mean using get_object_vars() is much better.
> > 
> > and in the example I've seen there:
> > 
> > you HAVE TO define all the variables you're using in a class scope. eg
> > class myClass {
> >   var $var1;
> >   var $var2 = array();
> > 
> >   function myClass($var) {
> >    $vars =get_object_vars($this);
> >    if (isset($vars[$var])) return $vars[$var];
> >    return false;
> >   }
> > }
> 
> Somewhat more elegant, yes. But: your function above is called myClass
> which is the classname and therefore this function is a _constructor_!
> As a constructor does not allow to return values, the above example
> would only work if you rename the function-name to something other than
> myClass!
> 
> -- 
> Regards
>  Marco
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php


-- 

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

Reply via email to