Re: why is '01' == '1.'?
| From: | Ron Korving | Date: | Thu, 15 Dec 2005 10:36:23 +0000 |
| Subject: | Re: why is '01' == '1.'? | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-21227@lists.php.net to get a copy of this message | ||
This may sound like a screwed up idea, and I'm not even sure if I would
support it, but just something that went through my mind:
A 2nd (flag) parameter for switch could do miracles:
switch ($var, SWITCH_STRICT)
{
}
and could be used for more than just strict checks:
switch ($var, SWITCH_STRICT | SWITCH_REGEXP)
{
case '/^[0-9]+$/': echo 'a number'; break;
}
or perhaps with byte-flags like with fopen():
switch ($var, 'r')
{
case '/^[0-9]+$/': echo 'a number'; break;
}
Just an idea, and perhaps gross, but very practical if you ask me.
- Ron
"Stefan Walk" <stefan.walk@gmail.com> schreef in bericht
news:4858f9d90512150059x71eec489t@mail.gmail.com...
See http://bugs.php.net/bug.php?id=23110
It's definitely a gotcha, especially if you use switch(){}, as there
is no way to do strict type checking there.
Regards,
Stefan