[PHP] Switch with different types
Author | Message |
---|---|
Posey | # Posted two hours ago |
![]() |
Hello. <?phpObviously this code doesn't work the way I intend it to. What are some solutions other than switching to if/else. |
Ads | |
Taurre | # Posted two hours ago |
Bare in mind that you're asking PHP, an interpreted high-level language, to juggle types on the fly. You're better off doing a type-check first before proceeding to the conditional loop. |
|
Celeri | # Posted one hour ago |
![]() |
Yeah, and he's asking precisely how to have PHP not juggle types. switch (true) { |
Kim Jong Un | # Posted one hour ago |
![]() |
Celeri's approach is probably the best. |
Posey | # Posted 7 minutes ago |
![]() |
Thanks all, I'll try these methods. |
Post a reply
Please be kind and courteous in your replies. Don't roast others for no reason.