You are here: Re: [PHP] function and interface in parameter list? « PHP « IT news, forums, messages
Re: [PHP] function and interface in parameter list?

Posted by Jochem Maas on 02/01/05 16:50

Marco Schuler wrote:
> Hi
>
> I found a function declaration in an open source project (in php5) and
> I could not find documantation for this. The function declaration is:
>
> public function registerComp(IComp $comp)
>
> Is it a kind of typecast?

no its a type declaration (is that the correct term). it states
that $comp must be an object of class IComp (or a subclass of it).
if $comp is not anj IComp object you get a fatal error.

this only works for classes. and it does not work in conjunction
with optional params e.g:

public function registerComp(IComp $comp = null) { /*....*/ }



(which IMHO sucks but hey c'est la vie! :-) )


>
> --
> Cheers!
> Marco
>

 

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

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