[nycphp-talk] Object Methods and Properties
Sol
sol2ray at yahoo.fr
Tue Jul 27 16:34:59 EDT 2004
> > >class MyClass {
> > > var $_header;
> > > var $_body;
> > > var $_footer;
> > >}
> > >
> > >and i am trying to use that code to dynamically
> choose which
> > variable to
> > >change.
> > >
> > >
> >
> > I've had luck with PHP 4.3.2 doing this:
> >
> > if ($append) $this->{'_' . $part} .= $val;
> >
> > Phil
> >
Ok now I see what you're trying to do.
Since you don't have 10000 part types you can do this
define('HEADER_TYPE', 1);
define('BOBY_TYPE', 2);
define('FOOTER_TYPE, 3);
member setter
function setPart($type, $val, $append){
switch($type){
case HEADER_TYPE:
code here;
break;
case BODY_TYPE:
code here;
break;
case FOOTER_TYPE:
code here;
break;
default:
invalid part type!
}
}
=====
Sol Touré
PHPBTREE
http://phpbtree.com
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
More information about the talk
mailing list