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

- Thread: https://externals.io/message/302
- Original archive: https://news-web.php.net/php.internals/302
- Started by Ford on 2003-03-26T12:34:15+00:00
- Messages: 2
- 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

---

## #302 — Ford — 2003-03-26T12:34:15+00:00

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

> -----Original Message-----
> From: Zeev Suraski [mailto:zeev@zend.com]
> Sent: 26 March 2003 01:47
> To: Ford, Mike [LSS]
> 
> At 03:27 25/03/2003, Ford, Mike               [LSS] wrote:
> > […]
> comparison, with
> > […]
> 
> I'd really not love to see it :)  Use an if-else chain of === 
> comparisons 
> instead if that's what you really need.

Oh, well, fair enough -- I can live with that, although I think it's a less
elegant way of programming it.  Still, nothing ventured nothing gained...!
;)

Cheers!

Mike

---------------------------------------------------------------------
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning & Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS,  LS6 3QS,  United Kingdom
Email: m.ford@lmu.ac.uk
Tel: +44 113 283 2600 extn 4730      Fax:  +44 113 283 3211

---

## #314 — Rasmus Lerdorf — 2003-03-26T16:41:59+00:00

URL: https://externals.io/message/302#314 · In reply to: #302

> > […]
>
> Oh, well, fair enough -- I can live with that, although I think it's a less
> elegant way of programming it.  Still, nothing ventured nothing gained...!
> ;)

Mike, changing this would break all sorts of stuff, and I think it would
confuse a lot of people.  If HTML form variables were somehow typed by the
browsers, then it might make sense, but people are going to write code
like:

  switch($input) {
    case 1:
      ...
    case 2:
      ...
    case 3:
      ...
  }

Forcing people to worry about the type on user input goes against the
basic nature of PHP.

-Rasmus
