php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #37656 Incorrect switch example
Submitted: 2006-05-31 16:50 UTC Modified: 2006-05-31 18:51 UTC
From: stevepburke at hotmail dot com Assigned:
Status: Closed Package: Documentation problem
PHP Version: Irrelevant OS:
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: stevepburke at hotmail dot com
New email:
PHP Version: OS:

 

 [2006-05-31 16:50 UTC] stevepburke at hotmail dot com
Description:
------------
In the documentation for the 'switch' statement, there is an example by scott at firefallpro dot com dated 22-Dec-2005 03:01.

In his second example, it doesn't seem to work properly unless the switch statement is "switch(true)" and not "switch($x)"

Reproduce code:
---------------
Example:
<?php
$x = 0;

switch($x) {
 case $x === "a":
   echo "a";
   break;
 case $x === "b":
   echo "b";
   break;
 default
   echo "default";
}
?>




Expected result:
----------------
default

Actual result:
--------------
a

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-05-31 18:51 UTC] nlopess@php.net
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.

Thank you for the report, and for helping us make our documentation better.


 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Thu Jul 17 14:04:04 2025 UTC