You are here: Re: Using a constant for abstraction? « All PHP « IT news, forums, messages
Re: Using a constant for abstraction?

Posted by M. Trausch on 11/17/05 06:18

sam wrote:
>
> $db = new $class_name ($user, $pwd, $dbName);
>
> Now, PHP knows that $class_name is a variable that contains the name of the
> class. That why it should work.
>

Hrm.

I didn't realize that you could use a variable like that in PHP. That's
a pretty nifty feature, actually. I never tried it quite like that,
probably because I'm thinking too much like I'm working in other
languages. What I wound up doing was working with eval(); and taking
advantage of PHP's variable substitution within double-quoted strings to
achieve the same effect, which worked rather nicely. I'll have to keep
this in mind for the future, though. That's pretty cool.

Thanks,
Mike

--
Strip the obvious trash from the header to send e-mail.

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация