You are here: Re: Overloaded functions and function pointers in PHP? « PHP Programming Language « IT news, forums, messages
Re: Overloaded functions and function pointers in PHP?

Posted by Chung Leong on 11/21/10 11:26

Peter Salzman wrote:
> Since PHP is a (weakly) typed language, is it possible to overload functions
> based on the type of their argument?

Kind of. You can always check the type of argument that's actually
passed with one of the is_* function and have the function behave
differently (e.g. array vs. scalar).

> Also, are there function pointers in PHP?

Kind of. In PHP, functions are referenced by name. If you do $func()
and the variable $func contains the name of a function, it will be
called.

> I'd like to be able to do this:
>
> foo('hello');
> foo(&bar());
>
> to produce this:
>
> foo hello foo
> foo barfoo foo

I don't think that's doable in any language.

 

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

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