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
 [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

Add a Patch

Pull Requests

Add a Pull Request

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-2024 The PHP Group
All rights reserved.
Last updated: Sun May 19 13:01:33 2024 UTC