Re: function with argument of type array
| From: | André Medeiros | Date: | Thu, 28 Jul 2005 11:07:09 +0000 |
| Subject: | Re: function with argument of type array | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-219474@lists.php.net to get a copy of this message | ||
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!