|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2021-10-12 19:03 UTC] requinix@php.net
-Summary: Switch...case feature request
+Summary: Switch...case as an expression
-Status: Open
+Status: Suspended
-Package: *Programming Data Structures
+Package: *General Issues
[2021-10-12 19:03 UTC] requinix@php.net
[2021-10-12 19:46 UTC] requinix@php.net
-Status: Suspended
+Status: Not a bug
[2021-10-12 19:46 UTC] requinix@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2026 The PHP GroupAll rights reserved. |
Last updated: Sun Jan 04 14:00:01 2026 UTC |
Description: ------------ I don't know if this is the right place but I'd like to be able to use switch...case like Java. Without using "break" and assigning the returned value to a variable directly. Test script: --------------- <?php $day = 2; $today = switch($day) { case 1 -> "Monday"; case 2 -> "Tuesday"; case 3 -> "Wednesday"; case 4 -> "Thursday"; case 5 -> "Friday"; case 6 -> "Saturday"; case 7 -> "Sunday"; default -> "Out of day range!"; } echo "Today is: " . $today . ".";