[nycphp-talk] Object Methods and Properties
Joe Crawford
jcrawford at codebowl.com
Tue Jul 27 16:38:52 EDT 2004
Sol,
not exactly what i am looking to do, i may have 100 class variables and
i do not want the class to create more, this is why i am checking the
values against the class vars ;)
Joe Crawford Jr.
On Tue, 2004-07-27 at 16:34, Sol wrote:
> > > >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
> _______________________________________________
> New York PHP Talk
> Supporting AMP Technology (Apache/MySQL/PHP)
> http://lists.nyphp.org/mailman/listinfo/talk
> http://www.newyorkphp.org
>
>
More information about the talk
mailing list