Reply to Re: [PHP] function with argument of type array

Your name:

Reply:


Posted by Andr� Medeiros on 11/01/29 11:22

On Thu, 2005-07-28 at 11:08 +0200, marc serra wrote:
> Hi, i want to know if it is possible to create a function and declare
> that one of its arguments is array type.
>
> In fact i want to do something like this
>
> function test(String $litteral, array $foo){
> .....
> }
>
> I got an error when i do something like this. Can you help me please?
>
> Thx,
>
> Marc
>

There is no way to do that. What you _CAN_ do, to ensure you're getting
an array is:

function test( $stringVar, $arrayVar ) {
if( is_array( $arrayVar ) ) {
// Thsi is an array
} else {
// Do error handling here
}
}

There are a few is_* functions that will help you on that. Good luck!

[Back to original 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

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