php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #42503 switch case matching
Submitted: 2007-08-31 18:08 UTC Modified: 2007-08-31 18:16 UTC
From: aya at eh dot org Assigned:
Status: Not a bug Package: Feature/Change Request
PHP Version: 5.2.4 OS: Irrelevant
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: aya at eh dot org
New email:
PHP Version: OS:

 

 [2007-08-31 18:08 UTC] aya at eh dot org
Description:
------------
What are the chances of changing the way in which switch case-matching works, from a '=='-equivalent to a '==='-equivalent?

Alternatively, how about a huge warning on the manual page for the switch statement for people who might reasonably expect that the attached code would act in a sane fashion?


Reproduce code:
---------------
switch (null)
{
case 0:
    echo "PHP case-matching is brain-damaged.\n";
    break;
case null:
    echo "PHP case-matching is sane.\n";
    break;
}


Expected result:
----------------
PHP case-matching is sane.


Actual result:
--------------
PHP case-matching is brain-damaged.


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-08-31 18:15 UTC] bjori@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

switch/case doesn't do strict checks
 [2007-08-31 18:16 UTC] bjori@php.net
(strict checking would break billions of scripts out there, so this wont change)
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Thu May 08 01:01:27 2025 UTC