NYCPHP Meetup

NYPHP.org

[nycphp-talk] type casting function arguments

Andrew Yochum andrew at plexpod.com
Fri Feb 10 15:03:12 EST 2006


On Fri, Feb 10, 2006 at 02:49:52PM -0500, Cliff Hirsch wrote:
> Is there any way to typecast a function argument like:
>  
> public function Partytime(int $argument)         // this actually
> expects an object of class int
>  
> or 
>  
> public function Partytime( (int)$argument)      // this barfs

No.  What you're trying to do is type hinting, which only works for the
compound types: classes (as of 5) and arrays (as of 5.1). See:
    http://us3.php.net/manual/en/language.oop5.typehinting.php

Maybe someday the other (scalar) primitives will make it in there.

Andrew
-- 
Andrew Yochum
Plexpod
andrew at plexpod.com
718-360-0879



More information about the talk mailing list