Re: AW: [PHP] PHP is Zero

[email protected] (Matijn Woudt)
Newsgroups php.general
Message-ID <CAC_gtuMxm7samEW7M3mRkpMcOGrMvDubmgn_TvrGF2O9z8=+uA@mail.gmail.com>
On Thu, Jun 13, 2013 at 1:49 PM, BUSCHKE Daniel <
[email protected]> wrote:

> To be more technical:
>
> If intval('8315e839da08e2a7afe6dd12ec58245d') would return NULL instead of
> 8315 then PHP would be still weak-typed and the developer could know that
> the conversion failed. Good idea? Of course NULL should be transparent in
> operations like +. So 0 + NULL should be still 0.
>
> Regards
> Daniel
>
>
It would just break too much. I see lots of scripts that have things like
this:

$var = '12 beers';

echo $var + 4;

and they expect it to be 16 of course.

Or what about badly trimmed strings, when reading from a file it can
include extra line endings and it's so much easier to just ignore that
because PHP will convert it just fine.

- Matijn
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.