Re: type hinting
| From: | Robert Cummings | Date: | Fri, 04 Jan 2008 18:51:35 +0000 |
| Subject: | Re: type hinting | ||
| References: | 1 2 3 4 5 6 7 8 9 10 11 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-34463@lists.php.net to get a copy of this message | ||
On Fri, 2008-01-04 at 18:46 +0000, Alain Williams wrote:
> On Fri, Jan 04, 2008 at 01:06:26PM -0500, Robert Cummings wrote:
> > <?php
> >
> > echo 'Foo: '.(0 + '5five')."\n";
> > echo 'Foo: '.((int)'5five')."\n";
> > echo 'Foo: '.(intval( ' 5five' ))."\n";
> > echo 'Foo: '.(sprintf( '%d', '5five' ))."\n";
> >
> > ?>
> >
> > All produce 5.
>
> But the string 'foobar' converts to a 0 (zero) -- not what is wanted.
If that's not what's wanted then use the more strict type hint that
generates E_RECOVERABLE. The conversion of 'foobar' to 0 (zero) is what
happens anywhere else when 'foobar' is converted to type int. Why change
that now?
Cheers,
Rob.
--
...........................................................
SwarmBuy.com - http://www.swarmbuy.com
Leveraging the buying power of the masses!
...........................................................