You are here: Re: [PHP] Get name of extending class with static method call « PHP « IT news, forums, messages
Re: [PHP] Get name of extending class with static method call

Posted by Torsten Roehr on 10/04/72 11:05

"Christopher Fulton" <christopher.fulton@gmail.com> wrote in message
news:bbbb9b3e050111092074cae919@mail.gmail.com...
> Not sure if this is the best way to do it or not, but you can do this
> and it should (untested code) work.....
>
> class Car {
> function drive() {
> return $this->getClassName();
> }
> function getClassName() {
> return "Car";
> }
> }
>
> class Porshe {
> function getClassName() {
> return "Porshe";
> }
> }
>
> $foo = new Porshe();
> echo $foo->drive();

Of course this might work but it requires the definition of such a method in
*every* class I have.

Any more ideas?

Thanks in advance!

Torsten

 

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

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