# Make switch/case to type sensitive comparison in PHP 5?

- Thread: https://externals.io/message/208
- Original archive: https://news-web.php.net/php.internals/208
- Started by Joey Smith on 2003-03-24T13:07:02+00:00
- Messages: 3
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #208 — Joey Smith — 2003-03-24T13:07:02+00:00

URL: https://externals.io/message/208#208

I was reminded tonight of the following 'feature' of switch:

$a = 0;
switch($a) {
	case 'somestring': echo 'Bug?'; break;
	case 0: echo 'Not a bug'; break;
}

This will echo 'Bug?' with PHP 4. It seems more logical to have switch
comparing with `T_IS_IDENTICAL` than with T_IS_EQUAL. Is this something that
might be changed as we move to PHP 5.0?

---

## #209 — Joey Smith — 2003-03-24T13:42:37+00:00

URL: https://externals.io/message/208#209 · In reply to: #208

See also bug 21990.

http://bugs.php.net/lbugs.php?id=21990


> I was reminded tonight of the following 'feature' of switch:
> 
> $a = 0;
> switch($a) {
> 	case 'somestring': echo 'Bug?'; break;
> 	case 0: echo 'Not a bug'; break;
> }
> 
> This will echo 'Bug?' with PHP 4. It seems more logical to have switch
> comparing with `T_IS_IDENTICAL` than with T_IS_EQUAL. Is this something that
> might be changed as we move to PHP 5.0?

---

## #221 — Zeev Suraski — 2003-03-24T17:57:42+00:00

URL: https://externals.io/message/208#221 · In reply to: #208

It's not a 'feature', it's a feature.  It's not likely to change, dynamic 
type conversion is one of the foundations of PHP.

Zeev

At 05:07 24/03/2003, Joey Smith wrote:
>I was reminded tonight of the following 'feature' of switch:
>
>$a = 0;
>switch($a) {
>         case 'somestring': echo 'Bug?'; break;
>         case 0: echo 'Not a bug'; break;
>}
>
>This will echo 'Bug?' with PHP 4. It seems more logical to have switch
>comparing with `T_IS_IDENTICAL` than with T_IS_EQUAL. Is this something that
>might be changed as we move to PHP 5.0?
