Posted by countach on 10/10/06 13:55
En las nuevas, el Bit Byte escribiσ:
> Noobie here (C++/C/Java experience though) ...
>
> Recently picked up PHP ...
>
> I want to pass an array to a function and then to use count on the
> passed variable - is this the way to do it (its an object method) :
>
> public function foo(array& $arr)
> {
> if (count($arr) < 1)
> throw new MyException("Blah blah ...") ;
> ....
> }
>
>
> I have two questions for the pros:
>
> 1). Is the function signature correct (valid syntax?)
> 2). Can count accept a reference type variable ?
1) Correct syntax:
public function foo(&$arr)
{
if (count($arr) < 1)
throw new MyException("Blah blah ...") ;
....
}
2) Yes
Navigation:
[Reply to this message]
|